Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying images in mysql 2

Status
Not open for further replies.

sheister

Programmer
Apr 29, 2008
3
GB
I have images stored in my database in mysql, and i was wondering if anyone knew how to display them in my webpage.
In dreamweaver, only some images display and others don't, even thought they're the same size and dimensions.

This is my code in php:

Code:
<td>&nbsp;<img src="images/<?php echo $row_rs_image['Img_Hotel1']; ?>" alt="Image" width="150" height="150"></td>

Any help would be greatly appreciated.
 
the img tag takes a url as a src attribute. this should normally point at a php script that delivers the relevant image header together with the binary contents of an image. typically the src attribute takes a query string in order to identify the image that you want to serve. there are plenty of examples in this forum.
 
I always store the images on the server and only the path (and perhaps title) in the database then when you call the row and assign a variable to it you only need to do this

echo <img src=$pathoimage title=$title alt=$title />
 
I totally agree with overflo, it is much more efficient and less processor intensive to store the pointer to the image file in your MySQL table.

LJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top