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

Link to comment
Share on other sites

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'); ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.