Another query quandary
Once again because of my clients poor database design I need help trying to solve a puzzle.
DATABASE DESIGN
Instead of having a separate Images table linked to the Item table, we have 11 image columns in the Item table AND 11 thumbnail columns.
(looks like this:
ID | ItemName | Image1 | Thumb1 | Image2 | Thumb2 | Image3 | Thumb3 | etc.
PAGE DESIGN
On the Item Details page we are displaying the large view of the first image. And originally the page had 10 hard coded places for the remaining 10 images displaying the thumbs and using a javascript displaying the full size images onclick.
ISSUE
This would actually work if each line item had 11 images but they don't. So what happens is most pages end up having broken images. I put a band-aid on it by creating a "No Image" image and displaying that for now. Tacky but better than it was.
MY GOAL
Create a query (and/or php) that allows me to use only one <img src> instance and repeats itself if an image is found in the next image column and so on. This way some pages may have 10 thumbs and others may only have 2 or 3. Hopefully that makes sense.
I've tried several lightbox and image viewer scripts but all of them just create slide shows from images in a directory. I need this to be dynamic.
I appreciate all advice of how to do this or better suggestions.