ok, not 100% sure how to explain but here goes
On the gallery_contents_results (table gallery_category_contents) page is a link to the page gallerycat_results.php?ID=gallery_1 (or gallery_2 etc) (table gallery_category) - this is where the images for each of the galleries gets uploaded.
when you get to gallery_category, gallery_ together with the ProductContentsID value from gallery_category_contents gets added to column GalleryPage in the gallery_category table so that now when you go to the insert/update pages for the gallery it knows which parent category it is associated with.
Now, what I have been trying to get my head round is how to another column - GalleryPageID - to be just with the ProductContentsID value (eg 1, 2 or 3 etc) to identify the parent category so that when I go to the insert or update page I can filter the sub categories based on that parent category ID
I have attached a zip with all 6 pages so you can see the flow....


