Hi, I am trying to display two or more images from a database and I cannot get them to display simultaneously.
I have a database table called 'tbl_images' which has two fields 'id' and 'image' here is the code for the database creation:
CREATE TABLE tbl_images (
id tinyint(3) unsigned NOT NULL auto_increment,
image blob NOT NULL,
PRIMARY KEY (id)
);
Images are successfully stored as a BLOB within the table.
Here is my php code to display the images, the code will successfully display the first image in the database, but will not then go on to display the second image in my database. I can display the second image if I choose to display it through its ID so all images are correctly stored.
<?php
header('Content-type: image/jpg');
include_once 'tables.php';
$query = "SELECT * FROM tbl_images";
$result = mysql_query($query);
for ($j=0; $j<$rows; ++$j)
{
$row = mysql_fetch_row($result);
echo $row[1] . "<br /><br /><br /><br /><br /><br /><br /><br /><br />";
}
//below is a second method that I tried which had the same result
/*
while($r=mysql_fetch_array($query))
{
header("Content-type: image/jpeg");
print $r['image'];
}
*/
?>
I have done some research into trying to fix this before posting here and I read a post in another forum which mentioned that you need to link to the php page which processes the displaying of images from a separate php file which actually displays the images. The post did not exlain how to do this and there were no more comments about it so I do not know if that is a correct solution.
I will be very grateful is anyone can help, Thanks.