Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.
I searched around a while and couldn't really find anything that helped me out. Here's the scenario:
I need a way to update real estate listings for my web site by entering information in text fields and uploading pictures.
I'm fairly new to using MySQL but I already know how to insert the data into an SQL database and how to upload pictures to a folder using php, but I was wondering what the best way is to deal with the pictures.
The only solution I can think of is to upload the files to their folder, and then save their paths to an array, and then save the array in the SQL database with all the other info. This way when I go to generate the html page I can just type something like:
I searched around a while and couldn't really find anything that helped me out. Here's the scenario:
I need a way to update real estate listings for my web site by entering information in text fields and uploading pictures.
I'm fairly new to using MySQL but I already know how to insert the data into an SQL database and how to upload pictures to a folder using php, but I was wondering what the best way is to deal with the pictures.
The only solution I can think of is to upload the files to their folder, and then save their paths to an array, and then save the array in the SQL database with all the other info. This way when I go to generate the html page I can just type something like:
<img src="php code to retrieve the path of the picture">
Would this work?
Thanks for your insight!
Steve Lindstrom
I'm a fan of storing images in the DB when needed and I think this is a great reason. Do you know how many photos you will be attaching to a particular listing? Remember that a CHAR/VCHAR only holds up to 255 characters for your array of filenames (10 pics * 15 char filename 'image_xxxxx.jpg' = 150 chars). Going VCHAR hinders the DB and storing images in the same table as the text info converts everything to VCHARs. If you store them in the database (separate table - KEY, POINTER, BLOB data) you can assign any number of images to a listing just by adding another entry to the DB and POINTing it to the listing in question. Any updating or deleting would never touch the listing table. And backups would contain everything, text, images, everything.