View Full Version : Retrive image from mysql database, slight problem

02-15-2006, 02:05 PM

i kept at my problem at trying to display an image from the database, i've manged to achieve my target, with the following:-

<img '.$row['image_size'].' src="view_image.php?image_name='.$_GET['image_name'].'"></td>


require ('database.php');

// get the image from the db
$sql1 = "SELECT img_data,image_name FROM manufact_img.thumb_images WHERE image_name = 'S320.jpg'";

// the result of the query
$result1 = mysql_query("$sql1") or die("Invalid query: " . mysql_error());

// set the header for the image
header("Content-type: image/jpg");
echo mysql_result($result1, 0);


however as you can see the image name is hard coded (view_image.php), on the main.php file i have a query which displays a specific image name, i want this to replace the hard coded value, any ideas.

but without using a submit button.

any help would be great

thanks in advance.