Jump to content


Photo

Display Images -PHP/MySQL


  • Please log in to reply
2 replies to this topic

#1 kritikia

kritikia
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 09 October 2006 - 11:16 PM

Hello all,

I am a newbie,,and I am trying to retrieve & display my blob data-my all images from the DB,
but with no great succes:(The only that I manage is to display 1 image

The code to display the first image:
<?php
$conn=mysql_connect("localhost","admin","");
mysql_select_db("Images") or die(mysql_error());

$sql="SELECT content FROM tbl_1";
$result=mysql_query($sql) or die("Invalid Query:" . mysql_error());
header("Content-type: image/jpeg");
$data=@mysql_result($result,0,"content");
echo $data;
mysql_close($conn);
?>

How can I modify this code to display all the images that are stored in the DB,
instead of only one(,that I define which one)
Can you help  me??Any idea?
Thanks!!

Kritikia



#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 09 October 2006 - 11:30 PM

Replace....

$data=@mysql_result($result,0,"content");
echo $data;

with...

while ($data = mysql_result($result,0,"content")) {
    echo $data;
}


#3 kritikia

kritikia
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 10 October 2006 - 06:31 AM

Hello thorpe,

I did it,but still the same result.. :(
It displays only one image,the first.

kritikia




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users