Illustration I
Sneakers (heading)
1. Nike (subheadings)
2. Addias
3. Fila
Boots
DressShoes
The illustration above is and accordion menu, which a users click in a heading and it display its subheadings. The equivalent of that illustration in code is below.
The code above shows two queries one for the headings and another for the subheadings and both use a while loop etc.PHP Code:$sql = 'SELECT id,Subject FROM menusubjects;';
$result = mysql_query($sql);
if($result && mysql_num_rows($result)!=0) {
echo '<ul id="nav-categories">';
while($row = mysql_fetch_assoc($result)) {
$uri = 'example1.php?subject='.urlencode($row['id']);
$class = !is_null($cat) && $cat==$row['id']?' class="selected"':'';
echo "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>';
if($submenu==false && !is_null($cat) && $cat == $row['id']) { // line 58
$sql2 = 'SELECT id,shoename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';';
$result2 = mysql_query($sql2);
if($result2 && mysql_num_rows($result2)!=0) {
echo "\n\t\t",'<ul class="submenu">',"\n";
while($row2 = mysql_fetch_assoc($result2)) {
$uri2 = $uri.'&menu='.urlencode($row2['id']);
$class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':'';
echo "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['shoename'],'</a></li>',"\n";
}
echo "\t\t",'</ul> <!-- end of ul.submenu -->',"\n";
}
$submenu = true;
}
echo '</li>',"\n";
}
echo '</ul> <!-- end of ul#nav-categories -->',"\n
My question is where the pointer is when a user click on the headings Sneakers causing to open it's three subheadings NIke, Adidas and Fila.
Where is the pointer at the beginning of the code or somewhere in the middle or at the end?





Bookmarks