my code is the following:
(This file calls the download_data.php file which is right bellow this one)
<html>
<head>
<title>Browse Upload Files</title>
</head>
<body bgcolor="white">
<?php
require_once('Connections/connection_include.php');
mysql_select_db($database_con, $con);
$query = "SELECT * FROM binary_data";
$result = mysql_query($query, $con) or die(mysql_error());
?>
<?php
if ($row = @mysql_fetch_array($result))
{
?>
<table>
<col span="1" align="right">
<tr>
<th>Short description</th>
<th>File type</th>
<th>Image</th>
</tr>
<?php
do
{
?>
<tr>
<td><?php echo "{$row["description"]}";?></td>
<td><?php echo "{$row["id"]}";?></td>
<td><?php echo "<img src='download_data.php?id={$row["id"]}'>";?></td>
</tr>
<?php
} while ($row = @mysql_fetch_array($result));
?>
</table>
<?php
}
else
{
echo "<h3>There are no images to display</h3>\n";
}
?>
</body>
</html>
///////////////////////////
download_data.php
///////////////////////////
<?php
global $id;
if($id) {
@MYSQL_CONNECT("xxx","xxx","xxx");
@mysql_select_db("xxx");
$query = "select bin_data,filetype,description from binary_data where id=$id";
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0,"bin_data");
$type = @MYSQL_RESULT($result,0,"filetype");
$description = @MYSQL_RESULT($result,0,"description");
Header( "Content-type: $type");
echo $data;
};