I've created an library that stores image names by ID and an image gallery table that stores the values of up to 15 images by image ID. The data looks like this:
ImageTable (id | name)
1 | one.jpg
2 | two.jpg
3 | three.jpg
4 | four.jpg
5 | five.jpg
6 | six.jpg
Gallery Table (id | slide1 | slide2 imageID ... and so on to slide15)
1 | 1 | 3 | 4 | null | null .... and so on to 15
1 | 2 | 5 | 6 | null | null .... and so on to 15
In this example the slide show 1(id1) would show one.jpg, three.jpg, and four.jpg
Slide show 2 would show two.jpg, five.jpg, and six.jpg.
If I pass a recordID (gallery.php?recordID=1) to the page I'm getting a perfect gallery recordset. Just one column comes in. I can't seem to figure out how to match that table row to the image table.
I think the problem is in the Query. I've tried dozens of loop and join queries but I can't seem to get anything to work I want to build a list of image names like this (html omitted):
PHP Code:
if ($row_imgGalery['slide1'] == $row_imageTable['id']){
echo $row_imageTable['name']; }
if ($row_imgGalery['slide2'] == $row_imageTable['id']){
echo $row_imageTable['name']; }
if ($row_imgGalery['slide3'] == $row_imageTable['id']){
echo $row_imageTable['name']; }
// and so on
The closest I have come is to get the first row to return the right value. From there on I get either nothing or the images in order. I'm probably going about this all wrong. Any ideas would be appreciated.