Jump to content

Archived

This topic is now archived and is closed to further replies.

SkyRanger

Tree Menu

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>";
}

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

×

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.