Page 1 of 1

Blob does not display multiple images from mysql database

Posted: Tue Jul 29, 2008 12:29 am
by nse111
Pls help this is urgent!
<?php
//header('Content-Type: image/jpeg');
header('Content-Type: text/html');
@mysql_connect("localhost","root","dba") or die("Error");
@mysql_select_db("gallery");
$result = mysql_query("SELECT * FROM paintings");
while($row = mysql_fetch_assoc($result)){
print $row[p_painting_id]."</br>";
//print $row[p_painting_image];
}
?>

this code displays all the painting ids available in the table 'gallery'.

but the below coding doesnt display all the corresponding images(of blob type).
Please tell em why.thanks in advance!!!

<?php
header('Content-Type: image/jpeg');
//header('Content-Type: text/html');
@mysql_connect("localhost","root","dba") or die("Error");
@mysql_select_db("gallery");
$result = mysql_query("SELECT * FROM paintings");
while($row = mysql_fetch_assoc($result)){
//print $row[p_painting_id]."</br>";
print $row[p_painting_image];
}
?>

Re: Blob does not display multiple images from mysql database

Posted: Tue Jul 29, 2008 12:51 am
by WebbieDave
Could you properly indent your code and display it within php tags? It will make it much easier for us to read. Have a look at the posting guidelines for more info:
viewtopic.php?f=1&t=8815

Re: Blob does not display multiple images from mysql database

Posted: Tue Jul 29, 2008 12:59 am
by nse111
Pls help this is urgent!
<?php
//header('Content-Type: image/jpeg');
header('Content-Type: text/html');

//database connectivity
@mysql_connect("localhost","root","dba") or die("Error");
@mysql_select_db("gallery");

//getting results from database table
$result = mysql_query("SELECT * FROM paintings");

//displaying the IDs of all the images available in the table
while($row = mysql_fetch_assoc($result))
{
print $row[p_painting_id]."</br>";
//print $row[p_painting_image];
}
?>

this code works and displays all the painting ids available in the table 'gallery'.

but the below coding doesnt display ALL the corresponding images(of blob type). it only displays just one image.

Please tell em why.thanks in advance!!!

<?php
header('Content-Type: image/jpeg');
//header('Content-Type: text/html');

@mysql_connect("localhost","root","dba") or die("Error");
@mysql_select_db("gallery");

$result = mysql_query("SELECT * FROM paintings");

while($row = mysql_fetch_assoc($result))
{
//print $row[p_painting_id]."</br>";
print $row[p_painting_image];
}

?>

hey hope this is clearer

Re: Blob does not display multiple images from mysql database

Posted: Tue Jul 29, 2008 2:30 am
by onion2k
You can only display 1 image at a time from a PHP script. You should be using HTML to set up multiple calls to your server, eg

Code: Select all

<img src="image.php?id=1">
<img src="image.php?id=2">
<img src="image.php?id=3">
<img src="image.php?id=4">
<img src="image.php?id=5">
 
Then 'image.php' would fetch the image with the id of whatever $_GET['id'] is.

Re: Blob does not display multiple images from mysql database

Posted: Tue Jul 29, 2008 3:22 am
by nse111
thanks I'l try that out!