dprichard Posted August 2, 2008 Share Posted August 2, 2008 Okay, I have been putting off trying to figure out how to do this and I am at a crossroad where I just gotta figure it out. I have the following Table 1 NewsCategoryId Category Name Table 2 NewsStoryId NewsCategoryId I want to be able to show it on my PHP page page like this: News Category1 - Story 1 - Story 2 - Story 3 News Category2 - Story 1 - Story 2 - Story 3 I have been searching google, but am not sure what I am trying to do is called so I am not getting good results. Any help or direction would be greatly appreciated. I know I can do the following, but I can't imagine doing a query for each result from table 1 is good practice and will probably be a load on the server: Query 1 While $row = mysql fetch array Query 2 But I am sure there is a better way. Quote Link to comment Share on other sites More sharing options...
dprichard Posted August 2, 2008 Author Share Posted August 2, 2008 Sorry, I guess more like this TableNewsCategories - CategoryId - CategoryName TableStories - StoryId - StoryName - CategoryId Then in my page like a tree I want to echo out CategoryName1 - Stories under that category CategoryName2 - Stories under that category Just not sure what doing this is called so I dont know how to query it in google to figure out how to do it. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 5, 2008 Share Posted August 5, 2008 I'm not sure I understand... if you JOIN the tables, you can iterate through the result and add a separator whenever you'd like. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.