Jump to content

Recommended Posts

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.