SkyRanger Posted March 4, 2012 Share Posted March 4, 2012 Can somebody please have a look at this. The Problem I am having is that only 1 entry for each month goes into the tree and for the life of me I can't figure out why. $queryyp = "SELECT YEAR(date) as year, MONTHNAME(date) as month, title FROM monsterpost ORDER BY date DESC"; // query to get the rows you want in the order that you want them, with the year and monthname specifically selected as well $resultyp = mysql_query($queryyp); $last_heading = null; // remember the last heading (initialize to null) while($rowyp = mysql_fetch_assoc($resultyp)){ $new_heading = $rowyp['year']; // get the column in the data that represents the heading $new_subheading = $rowyp['month']; // get the column in the data that represents the subheading if($last_heading != $new_heading){ // heading changed or is the first one $last_heading = $new_heading; // remember the new heading $last_subheading = null; // (re)initialize the subheading // start a new section, output the heading here... echo "<ol class=\"tree\"><li><label for=\"folder1\">{$rowyp['year']}</label> <input type=\"checkbox\" id=\"folder1\" /></li></ol>"; } // subheading under each heading if($last_subheading != $new_subheading){ // subheading changed or is the first one $last_subheading = $new_subheading; // remember the new subheading // start a new section, output the subheading here... echo "<ol><li><label for=\"subfolder1\">{$rowyp['month']}</label> <input type=\"checkbox\" id=\"subfolder1\" />"; } // output each piece of data under a heading here... echo "<ol><li class=\"file\">{$rowyp['title']}</li></ol></li></ol></li></ol>"; } Link to comment https://forums.phpfreaks.com/topic/258221-tree-menu/ Share on other sites More sharing options...
blacknight Posted March 4, 2012 Share Posted March 4, 2012 move $rowyp = mysql_fetch_assoc($resultyp) out of the while statement and vardump $rowyp and see what it says and post it... other then that i dont see any thing that stands out... Link to comment https://forums.phpfreaks.com/topic/258221-tree-menu/#findComment-1323677 Share on other sites More sharing options...
SkyRanger Posted March 4, 2012 Author Share Posted March 4, 2012 k, I am dumb as a brick. If it wasn't for PFMaBiSmAd helping me with the initial PHP code. I would still be pulling out my hair to figure it out. Does anybody know where I can find a tutorial to even start to try and figure out what I need to do. Link to comment https://forums.phpfreaks.com/topic/258221-tree-menu/#findComment-1323891 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.