ballouta Posted February 24, 2009 Share Posted February 24, 2009 Hi, I have this table called 'cases' articlenum category subcategory artlist descr price ========= ======== =========== ======= ===== ===== EM7023 Behuizingen Externe Case 3.5 inch HDD CASE 2.5inch IDE 7 EM7049 Behuizingen Externe Case 3.5 inch HDD CASE 2.5inch SATA 8 EM7077 Behuizingen HDD-ODD Case 3.5 inch 3.5" NAS Netwerk hdd 9 EM7090 Behuizingen HDD-ODD Case 3.5 inch 3.5" NAS Netwerk hdd 9 EM7090 Behuizingen PC Case none Barebone Foxconn M-ITX 114 i wrote this code to show the menu: cases and its subcategory, in the first four rows, each subcategory also has a subtitle too. is my code good and efficient? Thank you <?php //Showing the Cases menu and sub menus $query = "SELECT DISTINCT(subcategory) FROM `cases`"; $result = mysql_query($query); while( $row = mysql_fetch_array($result) ) { echo "<li><a href='show~sub.php?cat=cases&subcat=$row[subcategory]'>$row[subcategory]</a></li>"; $res= mysql_query("SELECT DISTINCT(artlist) FROM `cases` where `subcategory` = '$row[subcategory]' AND `artlist` !='none' "); $num=mysql_num_rows($res); if ($num >0) { echo "<ul>"; while( $ro = mysql_fetch_array($res)) { echo "<li><a href='show~all.php?cat=cases&subcat=$row[subcategory]&artlist=$ro[artlist]'>$ro[artlist]</a></li>"; } echo "</ul>"; } //if art list was found } //main while ?> Thank You Link to comment https://forums.phpfreaks.com/topic/146756-select-query/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.