Link Image with record in MySQL

PHTech

Senior Member
Joined
Aug 21, 2006
Messages
588
Reaction score
0
Location
Witbank
Hi there...

Is there any way how I can link any Image with a record in MySQL...? I know MySQL a bit but what I want to do is to create something similiar to a Shopping Cart website or something like that.

So if a record is displayed, it must display the Image corresponding to that record.

I would appreciate any easy steps I can follow to accomplish this...
 
not sure how detailed you need, but in short

1) Save the image as a fully qualified path name.
2) in the PHP code for the site, the image location is the DB field.
 
OK cool, but is there maybe something like a detailed tutorial on doing this... Because according to my knowledge, a record in the DB should point to a corresponding image using a filename. I just want to know how I can establish a MySQL code, so that for each record it locates the appropriate corresponding image, or how to assign an Image to a record.
 
What other technologies are you using? PHP?

There needs to be some sort of intermediary system in place that is responsible for managing the actual files and their representations in the mysql DB. Unless you want to use blobs, which I wouldn't recommend.

How I would do it is have a table representing the images with a few fields of data about the image, most importantly the filename and relative path.

So an image record may look like this:
ID | filename | path
1 | test.jpg | 200805

And your code would know that all images reside at /store/images/ so when displaying this image it can just append the path and filename to get /store/images/200805/test.jpg
 
Top
Sign up to the MyBroadband newsletter
X