Scenario: I have a table providing links to files that are stored in a mysql table. I can list the links via:
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>"; printf("%06s\n",$row['id']); echo "</td>";
echo "<td>" . $row['bibnumber'] . "</td>";
echo "<td>" . $row['laps'] . "</td>";
echo "<td>" . $row['time1'] . "</td>";
echo "<td>$" . $row['lap1'] . "</td>";
echo "<td>" . $row['quantitylaps'] . "</td>";
echo "<td>$" . $row['minlaps'] . "</td>";
echo "<td>" . $row['timestamp'] . "</td>";
echo "<td>" . "<a href=\"download.php?id={$row['id']}\">{$row['filename']}</a>" . "</td>";
echo "</tr>";
}
echo "</table>";
So then I want to click on the link that is outputted in above table and download the file. The link should take me to the page holding only this code below:
<?
if(isset($_GET['id']))
{
include ("static/config.php");
include ("static/opendb.php");
echo $_GET['id'];
$id = $_GET['id'];
$query = "SELECT filename, filetype, filesize, filecontent FROM tbl_quoteinfo WHERE id = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);
header("Content-Disposition: attachment; filename=$name");
header("Content-length: $size");
header("Content-type: $type");
echo $content;
include ("static/closedb.php");
exit;
}
?>
For some reason it seems the $_GET['id'] is not being set. I am stumped! Where did I go wrong?
Thanks in advance,
Wink-