justinh Posted December 8, 2008 Share Posted December 8, 2008 <div id=\"navbar\"> Select A Category </div> <div id=\"items\">"; $get_cats = mysql_query("SELECT * FROM tbl_category"); while($cats = mysql_fetch_array($get_cats)){ echo "<div id=\"category\" onclick=\"location.href=default.php?catid".$cats['cat_id'].";\"><b>".$cats['cat_name']."</b><br> <small>".$cats['cat_description']."</small></div></div></div></body></html>"; } Theres 5 categories in tbl_category, but for some reason: (only one is showing up) http://www.wmptest.com/clintormscart/default.php hmmm.. any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/136090-only-getting-one-row/ Share on other sites More sharing options...
justinh Posted December 8, 2008 Author Share Posted December 8, 2008 ughh sorry guys.. took a better look at the page, and noticed they're coming in at the bottom =P my mistake. Quote Link to comment https://forums.phpfreaks.com/topic/136090-only-getting-one-row/#findComment-709603 Share on other sites More sharing options...
wildteen88 Posted December 8, 2008 Share Posted December 8, 2008 Actually all five are being displayed. It's your HTML that is causing the problem. The following highlighted code should be outside of your while loop: <div id=\"navbar\"> Select A Category </div> <div id=\"items\">"; $get_cats = mysql_query("SELECT * FROM tbl_category"); while($cats = mysql_fetch_array($get_cats)){ echo "<div id=\"category\" onclick=\"location.href=default.php?catid".$cats['cat_id'].";\"><b>".$cats['cat_name']."</b><br> <small>".$cats['cat_description']."</small></div></div></div></body></html>"; } Fixed code: <div id=\"navbar\"> Select A Category </div> <div id=\"items\">"; $get_cats = mysql_query("SELECT * FROM tbl_category"); while($cats = mysql_fetch_array($get_cats)) { echo "<div id=\"category\" onclick=\"location.href=default.php?catid".$cats['cat_id'].";\"><b>".$cats['cat_name']."</b><br> <small>".$cats['cat_description']."</small></div>\n"; } echo "</div></div></body></html>"; Quote Link to comment https://forums.phpfreaks.com/topic/136090-only-getting-one-row/#findComment-709610 Share on other sites More sharing options...
justinh Posted December 8, 2008 Author Share Posted December 8, 2008 thanks for the reply caught it before you said something though Thanks again. maybe i should get some sleep lol Quote Link to comment https://forums.phpfreaks.com/topic/136090-only-getting-one-row/#findComment-709611 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.