toolman Posted December 17, 2009 Share Posted December 17, 2009 Hi there, I have a business directory which has main categories and sub categories. The main categories have a "level" of "1" and sub categories have a "level" of "2". I have managed to select and display the main categories, but I cannot work out how to display the sub categories under each main category. This is my PHP and MySQL: $result = mysql_query("select * from pmd_categories where level = '1' "); while($row = mysql_fetch_array($result)) { echo "<a href='category/" . $row['friendly_url'] . "'>" . $row['title'] . "</a><br />"; } Could someone help me out to display the sub categories under each main category? Many thanks. Link to comment https://forums.phpfreaks.com/topic/185512-help-selecting-categories-from-directory/ Share on other sites More sharing options...
JAY6390 Posted December 17, 2009 Share Posted December 17, 2009 Some info on the table structure would be helpful, such as do the subcats have parent ids? Link to comment https://forums.phpfreaks.com/topic/185512-help-selecting-categories-from-directory/#findComment-979433 Share on other sites More sharing options...
toolman Posted December 17, 2009 Author Share Posted December 17, 2009 Hi, The sub cats do not have parent IDs. I think the only way they are different is the "level". The main category has a level of 1 and the sub categories have a level of 2. Link to comment https://forums.phpfreaks.com/topic/185512-help-selecting-categories-from-directory/#findComment-979444 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.