Blob does not display multiple images from mysql database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nse111
Forum Newbie
Posts: 3
Joined: Tue Jul 29, 2008 12:25 am

Blob does not display multiple images from mysql database

Post 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];
}
?>
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: Blob does not display multiple images from mysql database

Post 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
nse111
Forum Newbie
Posts: 3
Joined: Tue Jul 29, 2008 12:25 am

Re: Blob does not display multiple images from mysql database

Post 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
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Blob does not display multiple images from mysql database

Post 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.
nse111
Forum Newbie
Posts: 3
Joined: Tue Jul 29, 2008 12:25 am

Re: Blob does not display multiple images from mysql database

Post by nse111 »

thanks I'l try that out!
Post Reply