Re: retrieving images

From: Date: Mon, 02 Apr 2001 05:02:57 +0000
Subject: Re: retrieving images
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-8110@lists.php.net to get a copy of this message
Yes, exactly. What you want are image tags, as in <image src="getimage.php?ID=<?echo rs('ID')?>" so that you have one php file that is responsible only for getting the images specified by the querystring, setting the contenttype and then echoing this image out as binary write essentially. The page that fetches the keys of what you want to display then calls this other file via the image tag...Seems to work fine in PHP/MySQL - and the same techinique is applicable in ASP...an IBM DB2 UDB database is currently not accepting "blobs" for me for some unknown reason...who knows? Best of Luck, Phil Jackson http://www.fractal-vibes.com . "Stuart J. Browne" wrote: > 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 > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#8110) next »