I have a mysql table that has id, name, type, size, content, and link. I have pages download.php and showimage.php. I want the link to affect the image so when the user clicks it sends them their. I only created showimage.php cause I had ran out of options on how to link and was hoping i could extract the link somehow from download.php. Heres the code for both.
Download.php
<?php
include 'config3.php';
include 'opendb.php';
$query = "SELECT name, type, size, content, link FROM `upload` ORDER BY RAND() LIMIT 1";
$result = mysql_query($query) or die('Error, query failed');
while($row= mysql_fetch_array($result)){
$content = $row['content'];
$size= $row['size'];
$type= $row['type'];
$link= $row['link'];
header('Content-type: $type');
echo $content;
}
include 'closedb.php';
?>
Showimage.php
<html>
<head>
<title>Image Test</title>
</head>
<body>
<h1>Displaying image from database</h1>
<a href="download.php"><img src="download.php" height="250" width="250"/></a> </body>
</html>
Download.php code above only shows the image. I've tried playing with download.php to echo "<a href='".$link."'/><img src='".$content."' /></a>";
but when i do this the image turns into a huge jarbled mess. Any suggestions?