Thread: My dynamic menu
View Single Post
Old 01-19-2008, 10:06 AM   #1 (permalink)
lesP
The Contributor
Newcomer 
 
Join Date: Jan 2008
Posts: 27
Thanks: 1
lesP is on a distinguished road
Default My dynamic menu

Hi there!

I have written a dynamic menu. In one tabel I have the titles of the menu. Ex: Home & shop etc.

In another table I have the subtitles. Ex: When you click on shop, all the subtitles connected to shop should appear right underneath the title. Like this:

Home
Shop(active)
Good shop
Medium Shop
Bad shop
Contact

I think you understand. I connect those subtitles and titles with a id_parent, so all subtitles have the same id_parent as their respective title. But instead of the subtitles just appearing right under its title, it appears under every title in the menu. It extracts the right subtitles from the database, but print them under all titles. I think the problem lies in, how the udskriv_menu(); is chosen, but I do not know how to solve it...

Here is my title:

php Code:
$query=mysql_query("select * from a_spil order by titel asc");
while ($result=mysql_fetch_array($query)){



           echo '<div style="width:100%;height:19px;_height:24px;padding-top:5px;_padding-top:1px;">';
  echo '<div style="float:left;display:inline;" style="margin-top:4px;">';
   echo '<a href="index.php?mode='.$result[mode].'&mode2=spil&action=vis_spil&spil='.$result[id].'&overordnet='.$result[id_parent].'" title="Vuelta a Espaņa" style="margin:4px 0px 0px 17px;" class="menupunkt">';
    echo $result[titel];
   echo '</a>';
  echo '</div>';
  echo '<div style="float:right;margin:5px 0px 0px 0px;_margin:9px 0px 0px 0px;"><img src="grafik/menupunkt_pil.gif" style="margin-right:16px;"></div>';
 echo '</div>';
 echo '<div style="height:1px;width:100%;"><img src="grafik/menupunkt_skillelinie.gif" alt="" /></div>';
// If any title has been chosen, now the subtitles will appear in this form.
//overordnet is the id_parent of the title

if ($_REQUEST['overordnet']=="3333"){
 udskriv_menu();
// echo '<div style="height:1px;width:100%;"><img src="grafik/menupunkt_skillelinie.gif" alt="" /></div>';

 }
}
Here is my function:
php Code:
function udskriv_menu(){

 $aquery=mysql_query("select * from a_kategorier where id_parent='$_REQUEST[overordnet]' order by sortering asc");
 while($result=mysql_fetch_array($aquery)){
   $aquery2=mysql_query("select * from a_spil where id_parent='$id_parent'");
while ($result2=mysql_fetch_array($aquery2)){

  echo '<div style="width:100%;height:19px;_height:24px;padding-top:5px;_padding-top:1px;">';
   echo '<div style="float:left;display:inline;" style="margin-top:4px;">';
    echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="index.php?mode='.$_REQUEST['mode'].'&mode2='.$result["struktur"].'&action=vis_'.$result["action2"].'&spil='.$result2["id"].'&id='.$result["id"].'" title="'.$result["titel"].'" style="margin:4px 0px 0px 17px;" class="menupunkt">';
     echo $result["titel"];
    echo '</a>';
   echo '</div>';
   echo '<div style="float:right;margin:5px 0px 0px 0px;_margin:9px 0px 0px 0px;"><img src="grafik/menupunkt_pil.gif" style="margin-right:16px;"></div>';
  echo '</div>';
  echo '<div style="height:1px;width:100%;"><img src="grafik/menupunkt_skillelinie.gif" alt="" /></div>';
  $nummer++;
  $antal_emner='0';
  udskriv_undermenu($result["id"],1);

}
}
}

Last edited by Wildhoney : 01-19-2008 at 01:00 PM. Reason: A little syntax highlighting
lesP is offline  
Reply With Quote