Secondary Loop Malfunction
Posted: Mon Jun 19, 2006 6:28 pm
Good Day Devnet!
I am using a database to populate a menu that uses CSS and JavaScript to create a slide-out sub menu.
It uses one loop to create the categories, and then a loop inside for the subcategories.
The second loop isn't working. It populates the first menu, but then doesn't finish and no other menus are loaded.
I have provided links to working and non working examples in the below code.. thanks a lot for looking.
I am using a database to populate a menu that uses CSS and JavaScript to create a slide-out sub menu.
It uses one loop to create the categories, and then a loop inside for the subcategories.
The second loop isn't working. It populates the first menu, but then doesn't finish and no other menus are loaded.
I have provided links to working and non working examples in the below code.. thanks a lot for looking.
Code: Select all
echo "<div id='dhtmlgoodies_slidedown_menu'><ul>" ;
// Begin PHP Loop #1 - Works ------->
$sql = "SELECT COUNT(*) FROM var_section_names";
$numrecord = mysql_query($sql);
$numrecords = mysql_fetch_array($numrecord);
$numrecords[0];
$intRecsPerPage=12;
if($_POST["intpage"]=="")
{
$intpage=1;
}
$sql = "SELECT * FROM var_section_names ORDER BY Section_N_Weight ASC";
$result = mysql_query($sql) or die (mysql_error());
for($x = (($intpage-1) * $intRecsPerPage); $x < (($intpage-1) * $intRecsPerPage) + $intRecsPerPage; $x++)
{
if($x >= $numrecords[0])
{
break;
}
$sectionresults = mysql_fetch_array($result);
$sectionName = $sectionresults["Section_N_Name"];
$sectionNID = $sectionresults["Section_N_ID"];
echo "<li><a href='#'>$sectionName</a>";
echo "<ul>";
// Begin Static Loop - Works -------> http://www.thevariables.com/_/
echo "<li><a href'#'>Roll Out 1</a></li><li><a href'#'>Roll Out 1</a></li>";
// End Static Loop - Works ------->
// Begin PHP Loop #2 - Doesn't Work -------> http://www.thevariables.com/_/indexBad.php
$sql2 = "SELECT COUNT(*) FROM var_sections WHERE Section_AID = '$sectionNID'";
$numrecord = mysql_query($sql2);
$numrecords = mysql_fetch_array($numrecord);
$numrecords[0];
$intRecsPerPage=12;
if($_POST["intpage"]=="")
{
$intpage=1;
}
$sql2 = "SELECT * FROM var_sections WHERE Section_AID = '$sectionNID' ORDER BY Section_Weight ASC";
$result = mysql_query($sql2) or die (mysql_error());
for($x = (($intpage-1) * $intRecsPerPage); $x < (($intpage-1) * $intRecsPerPage) + $intRecsPerPage; $x++)
{
if($x >= $numrecords[0])
{
break;
}
$sectionsresults = mysql_fetch_array($result);
$sectionsPT = $sectionsresults["Section_PT"];
$sectionsID = $sectionsresults["Section_ID"];
echo "<li><a href='#'>$sectionsPT</a></li>";
}
echo "</ul>";
// End PHP Loop #2 - Doesn't Work------->
echo "</li>";
}
// End PHP Loop #1 - Works ------->
echo "</ul>";