Re: retrieving images

From: Date: Mon, 02 Apr 2001 01:03:11 +0000
Subject: Re: retrieving images
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8103@lists.php.net to get a copy of this message
Hello, I'm trying to retrieve and output all the binary images in my images table. This is what I have, $result = mysql_query("SELECT * FROM images",$db); if ($myrow = mysql_fetch_array($result)) { // display list if there are records to display do { $filetype = ($myrow["filetype"]); header("Content-type: $filetype"); echo $myrow["binary_junk"]."<br>\n"; } while ($myrow = mysql_fetch_array($result)); } else { // no records to display echo "Sorry, no records were found!"; When I run this, it only returns the first image in the table. Have really know idea where to go from here. Is one image all that can be done? Ok.. some information for you, as you seem to mis-understand some things here... A web-browser can handle certain pices of information being thrown down it's gullett.. The Content-type: is what determines this. If you start by throwing it an image/gif, then it will expenct a gif to come down. If you start throwing "<BR>"'s down, it will not only corrupt the image, but not do anything remotely related to HTML. Basically what you need to do is to set up a second PHP routine which grabs the binary data from the dataqbase and displays it, using <IMG> tags. The first routine just sets up the <IMG tags pointing to the second.. I've got an example of the code required to do something like this if you want to take a look.. (http://elfgrove.virtual.net.au/~bekar/test.phps) hope this helps. bkx

« previous php.db (#8103) next »