deadlyp99 Posted March 2, 2009 Share Posted March 2, 2009 Well i'm working on creating a forum, and so I'm playing around with getting my category listing as a starter towards the rest of the hell i'm creating. Anyways My problem is it will skip the first row, and I've got no idea why. Some insight would be nice, and any coding practice errors I've made can surely be pointed out as well. I welcome the criticism, it helps in the end. My Table: ID category_title sub_categories 1 News Announcements~Updates~Worklog 2 Other Spam~Spam~Spaaaaam! 3 placehold ugh~what~no My Code: <?php function retrieve_forums(){ // Lets start by starting the first level of display with the category $get_category = "SELECT * FROM `category` ORDER BY `ID`"; $resulting_categories = mysql_query($get_category) or die("wtfx: <br />".mysql_error()); // build an array of category and create sub-categories under if (mysql_fetch_row($resulting_categories)==0){ die("You need to create main categories...."); } else { while($category_row = mysql_fetch_array($resulting_categories)){ echo $category_row['category_title'] . "<br />"; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/147593-solved-first-row-skipped-confused/ Share on other sites More sharing options...
phant0m Posted March 2, 2009 Share Posted March 2, 2009 mysql_fetch_row($resulting_categories)==0 with this statement, you throw your first category out into nothingness use mysql_num_rows instead <?php function retrieve_forums(){ // Lets start by starting the first level of display with the category $get_category = "SELECT * FROM `category` ORDER BY `ID`"; $resulting_categories = mysql_query($get_category) or die("wtfx: <br />".mysql_error()); // build an array of category and create sub-categories under if (mysql_num_rows()==0){ die("You need to create main categories...."); } else { while($category_row = mysql_fetch_array($resulting_categories)){ echo $category_row['category_title'] . "<br />"; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/147593-solved-first-row-skipped-confused/#findComment-774828 Share on other sites More sharing options...
deadlyp99 Posted March 2, 2009 Author Share Posted March 2, 2009 Interesting. I don't remember that happening before though, but I havent touched mysql in many months, I've only worked on stuff with api's for their statements. Thanks, I feel stupid but I'll remember it, at least till I forget it, but hopefully it will click. Quote Link to comment https://forums.phpfreaks.com/topic/147593-solved-first-row-skipped-confused/#findComment-774837 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.