Displaying all images in table using PHP
Posted: Thu Mar 16, 2006 1:32 pm
Hi guys,
This is giving me a lot of problems. I am able to insert in images in a table, and display ONE image. But I want to display all the images in the table, this is me giving trouble, this code at the moment is displaying the same image ten times.
As I am incrementing the $ID variable, I want different images to be displayed, but I just keep getting the same one. I do know it is working to some extent, when I put in this statement(echo $name I do get all the image names.
------------------------------
CODE
Burrito: Please use
This is giving me a lot of problems. I am able to insert in images in a table, and display ONE image. But I want to display all the images in the table, this is me giving trouble, this code at the moment is displaying the same image ten times.
As I am incrementing the $ID variable, I want different images to be displayed, but I just keep getting the same one. I do know it is working to some extent, when I put in this statement(echo $name I do get all the image names.
------------------------------
CODE
Code: Select all
<?
$db = mysql_connect("xxxx", "xxxx","xxxx");
mysql_select_db("project140",$db);
$id = 1;
while($id<10){
$query = "SELECT name, type, size, content FROM upload where id ='$id'";
$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);
if ($_REQUEST[gim] == $id) {
header("Content-length: $size");
header("Content-type: $type");
echo $content;
exit;
}
?>
<html>
<title>Upload an image to a database</title><body>
<center><img src=?gim=<? echo $id ?> width=160 height=160><br>
</body>
</html>
<?
$id++;
}
?>Code: Select all
tags when posting code in the forums
removed host/un/pass[/size]