...

View Full Version : retrieve all images from db



mrjameer
01-03-2007, 06:09 PM
hi,

i want to retrieve all images which are present in mysql table.i want to display 5 images per row.but when i fetch image it shows one image only.here is my code.how to solve this problem.any of your help will be appreciated
<?php

$conn4=mysql_connect("localhost","","");
mysql_select_db("jo",$conn4);


$sql = "SELECT name, type, size, content FROM image_upload";
$result = mysql_query($sql,$conn4) or die(mysql_error());



list($name, $type, $size, $content) = mysql_fetch_array($result);

header("Content-Disposition: attachment; filename=$name");
header("Content-length: $size");
header("Content-type: $type");
echo $content;

?>

thanks
mrjameer

CFMaBiSmAd
01-03-2007, 06:22 PM
In a browser, to display an image, each image must be in the form -

<img src="a_url_that_results_in_an_image" alt="">You cannot directly output the contents of an image using inline code in the web page.

firepages
01-03-2007, 11:16 PM
so you will have to call your images like so..

<img src="script.php?im=1" alt="" />
<img src="script.php?im=2" alt="" />
etc

where script.php is similar to your above code,

This is why storing images in a DB is a bad idea (IMO).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum