StefanRSA Posted November 3, 2008 Share Posted November 3, 2008 Hi... I have a MySql DB with two tables... adcat and adsubcat. My code is as follow: $result = mysql_query( "SELECT * FROM ".$prefix."adcat JOIN adsubcat ON adsubcat.catid=adcat.id ORDER by sortorder,id" ) or died("Record NOT Found: ".mysql_error()); ?> <center> <div id="wrapper"> <? while ($db = mysql_fetch_array($result)) { echo "<div id =".$db[div].">".$db[name]."<br><div id=".$db[divsub].">".$db[subname]."</div></div>"; } ?> <div class="clear"> </div> </div> </center> My Problem is that I am trying to put my results in seperate blocks with the adcat.name as heading and then all subnames connected to adcat.name below that... What is happening now, is that I get a block for each line of the joined tables.... Can anybody please help me? Link to comment https://forums.phpfreaks.com/topic/131162-mysql_fetch_array-join-two-table-query-problem-help-pls/ Share on other sites More sharing options...
StefanRSA Posted November 3, 2008 Author Share Posted November 3, 2008 Or let me put it this way... I have two tables. One is categories. The Other is subcategories. I want to categorize all the subcategories under the categories... Please look at my code and tell me what I am doing wrong. At this moment I have the following: CAT1 CAT1 CAT2 CAT1 SUB1 CAT1 SUB2 CAT2 SUB1 Instead of: CAT1 CAT2 CAT1 SUB1 CAT2 SUB1 CAT1 SUB2 Please help.... Link to comment https://forums.phpfreaks.com/topic/131162-mysql_fetch_array-join-two-table-query-problem-help-pls/#findComment-681016 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.