Displaying an image within a mysql database via php

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
joe1986
Forum Newbie
Posts: 3
Joined: Tue Mar 31, 2009 5:11 pm

Displaying an image within a mysql database via php

Post by joe1986 »

Hi there,

I am currently developing a localhost php application to retrieve report details, etc. from a mysql database. I have an idea at the moment for uploading images to one table in the database (links not blobs) and taking a field from another table comparing the contents of this particular field to the images names in the images table, and if there any matches (or similar) then to display within the PHP page.

For example:

Table 1
+---------------------------+
| Field 1 | Field 2 |
|data123 | data456 |
+---------------------------+

Table 2
+----------------------------+
| Field 1 | Field 2 |
|data123.jpg | diff.jpg |
+----------------------------+
data123 from one table matches data123.jpg from the other table, so that image is displayed. Im not sure how to implement something like this, although I suspect it might be simple "if field = to field then display, else dont" sort of thing...I hope this sort of makes sense.

Any suggestions?

Cheers

Joe
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Displaying an image within a mysql database via php

Post by jaoudestudios »

I would not use the name of the image, but use an ID - this way there is no room for mistakes :)

You would JOIN the tables.
joe1986
Forum Newbie
Posts: 3
Joined: Tue Mar 31, 2009 5:11 pm

Re: Displaying an image within a mysql database via php

Post by joe1986 »

Thanks for the reply. I have decided to leave the idea now, and to just display an image from the link in one database table (nice and simple I imagine). Not sure how to do this, but im sure there are tutorials available. If anybody knows of any, please let me know!

Cheers

Joe
Post Reply