Retrieving Correct Data From Link

I have two tables that are joined together but I cannot seem to retrieve ALL the data from a selected linked category–maybe this is a PHP thing; let me know and I’ll move to the other forum.

TABLE 1
cat_id category
1 Just For Fun
2 Special Results
3 All for It

TABLE 2
gallery_id cat_id filename caption
1 1 xxxxxx.jpg ;alskjf;laskdjf
2 2 xxxxxx.jog ;alskdjf;lkajsdf
3 3 xxxx.jpg 0987a;lkjhd
4 1 ss.jpg ;kj;lakjsd

This is my query:
SELECT *
FROM T1 JOIN T2 ON T2.cat_id = T1.cat_id
WHERE T1.cat_id = T2.cat_id

Say I click on the link for Category 1; instead of getting all of the photos for Category 1, I get just one and one of each other category. I tried GROUPING, but I got the same results.

Where am I missing it?

your problem is entirely a php issue

just hang on, one of the moderators will move this thread over there shortly…

:slight_smile:

Please share the code you want us to help you fix.

Here’s a query that would retrieve all the images in category 1 (and the category info):

SELECT
  category,
  gallery_id,
  filename,
  caption
FROM
  T2 
INNER JOIN 
  T1 ON T1.cat_id = T2.cat_id
WHERE
  T2.cat_id = 1

Dan,

Thank you! I knew I was missing something and thank you for pointing that out to me!