You'd need 3 pages. The products page which displays all products, the image which will display the image, and the product details page which will show all the details about the product.
Code:
<?PHP
//display all products
$query = mysql_query("SELECT * FROM `products`") or die(mysql_error());
while($row=mysql_fetch_assoc($query)) {
//format the output
echo '<a href="fullProduct.php?id='.$row['id'].'"><img src="image.php?id='.$row['id'].'">'.$row['name'].'</a>';
}
Code:
<?PHP
//display image
$id = $_GET['id'];//FILTER!!
$query = mysql_query("SELECT `image` FROM `products` WHERE `id`='$id'") or die(mysql_error());
while($row=mysql_fetch_assoc($query)) {
$im = imagecreatefromstring($row['image']);
if ($im !== false) {
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
}
else {
echo 'An error occurred.';
}
}
Code:
<?PHP
//display full product
$id = $_GET['id'];//FILTER!!
$query = mysql_query("SELECT * FROM `products` WHERE `id`='$id'") or die(mysql_error());
while($row=mysql_fetch_assoc($query)) {
//format the output
}