Help Creating Interface!

Hey. I have been trying and trying to think of ways to make this interface work without making it really huge and maybe unnecessary.

A. I have two tables in a database: 1 called ‘category’ the other called ‘pages’

Now, I am trying to create an interface where the user will see a a list of categories. Under each category will be the list of pages that correspond to that category. The pages are called from the ‘pages’ table by their field “catid” (catid = #) and then put under the category that corresponds to that number. The categories are called from the ‘category’ table by their ‘catid’ also. Basically, everything should match up.

But for some reason I haven’t been able to get it to work, and my head is really really hurting from trying to do this all day long. So, I wanted to ask you what you think I should do to solve this problem.