PHP Dispalying - Assigning an Image from MySQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
meandrew
Forum Commoner
Posts: 49
Joined: Mon Feb 24, 2003 1:03 pm

PHP Dispalying - Assigning an Image from MySQL

Post by meandrew »

Hi All :?:

I am wondering how simple it would be to use a table ID from MySQL and dispaly and image assigned to the ID.

I guess the tricky bit is assigning an identify to the image for the selected ID.

Has anyone got any ideas to how I should approach this?

Andrew
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

It depends how you save the image really.

Option 1: saves the image as whatever.jpg and add a field in the table that also holds that value. echo that out within an <img src tag and jobs a goodun.

Option 2: save the image without an extension just as the row_id (ie '12') and read the headers through scripting before outputting the file - nice method for unix boxes.
meandrew
Forum Commoner
Posts: 49
Joined: Mon Feb 24, 2003 1:03 pm

PHP Dispalying - Assigning an Image from MySQL

Post by meandrew »

good point... The image can be uploaded manually into its own directory. I guess the what I need to do first is establish the association code for CityID to $CityID.gif this shouldn't be a problem really hopefully I will be posting a solution to my own problem shortly :)

Andrew
Post Reply