Jump to content

How to retrive image from mysql and dispaly it on ie.


sundeep

Recommended Posts

Well the basic query would be

 

SELECT image_field_name FROM image_database_name

 

You'd use mysql_query to run your query. Next you'll want to use mysql_fetch_array retrieve the results. You'll wan to use a while loop to loop through your results. Within your while loop you'll use something like

echo '<img src="'.$row['image_field_name'].'">';

to dispaly your images

Hey,

 

if they are stored as BLOB (Binary), my best bet is to do a separate script (let's say get_image.php?id=xxx) and pass in the ID of the item:

 

<?php echo '<img src="get_image.php?id='.$row['item_id'].'" />'; ?>

 

And get_image.php will go get the image in the database according to the item ID passed in.

 

This works pretty good in all browsers (maybe won't will very old one).

 

Make sure to set the header accordingly:

<?php header('Content-type: image/jpeg'); ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.