Synch DB and Image files

wxdqz

New Member
I have a site that stores and displays a store抯 products with their image, name and description. Mysql holds the item抯 id, name, description, dimension, price, etc. and the images are stored independently from the database. For a produce with an id of 12, the corresponding image files would be named m12.jpg (medium image), L12.jpg (large image), and a12.jpg (alternate image.) The site functions well but after some time database accumulates records without images and image files without database records.
I need to write a script that will search and display all database records that are missing image files. I also want to write a script that will display (and then prompt for a delete) all of the image files that no longer have database records.
The first one is easy and I already wrote the script for it. The second one, however, is giving me a headache.

I want it run through all the medium images (m12.jpg.)
If it finds a corresponding mysql record than do nothing. (every file has at least a medium image)
If the record for that image doesn抰 exist, however, I want it to delete that image and its corresponding large (L12.jpg) and alternate (a12.jpg) images.

If anyone has any ideas on how to do this I will be forever in your debt.

Thanks for your help ?sorry for the long post,
Mark
 
Back
Top