Display Image in Query

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
darren_plehn
Forum Newbie
Posts: 11
Joined: Tue Oct 06, 2009 8:48 pm

Display Image in Query

Post by darren_plehn »

What code do you need to allow pictures to come up in a query? This tutorial works perfect, but I need a modification so that I can use a select statement and have all the pictures show.
http://www.phpbuilder.com/columns/florian19991014.php3
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Display Image in Query

Post by pickle »

Images stored in a database are stored as BLOB columns (or MEDIUMBLOB or LARGEBLOB, etc). Those columns store the raw image data. To get the images stored in the database to display on screen, you need to build a PHP file that you reference from your HTML like you would a regular image. That PHP file loads the image data from the database, sends the appropriate JPG/GIF/PNG/?? headers, then sends the image data - just like a regular image would.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply