I am trying to make a simple HTML menu system. I am having problems
displaying menu links under the correct submenu from a loop.

I have a database with two tables. One table holds menu and sub menu
headings and the other table holds the contents of each submenu (the
actual menu links and names).  I need to display the menu title and then
the sub menu title from table 1 and then display the submenu contents or
links from table 2 and then display the next set of links under the
correct submenu

Example output would look like this:

Say person clicks on Admin menu which is already displayed then the
networking submenu heading will display along with the submenu links:

   Example:   Admin                            (main menu title from db
table 1)
                        Networking                (submenu title , from
db table 1
                                ping                    (Link to ping
from db table 2)
                                traceroute           (Link to ping from
db table 2)
                                nsloopup etc........


I don't know how to go about outputing the links under the correct
submenu.  The main menu is no problem. I am thinking I would need a loop
within a loop.

The query I use: $query = "SELECT * FROM menutable, elementstable WHERE
menutable.menutable_id = elementstable.menuid AND menutable.mainmenu =
'Admin' ";

$result = mysql_db_query("menus", $query);

This loop simply assigns variables and prints out all output under the
main menu called Admin.  The problem is how do I display

  while ($r = mysql_fetch_array($result)) {

// start menu table (table holds main menu/sub menu headings
            $menutable_id = $r["menutable_id"];
            $menunumber = $r["menunumber"];
            $mainmenu = $r["mainmenu"];
            $submenu = $r["submenu"];
// start elements table (table that holds the links and names of each
link)
// element_id references menu table
            $element_id  = $r["element_id"];
            $element = $r["element"];
            $url = $r["url"];
            $menuid = $r["menuid"];

// next display data this is wrong cause it displays 1 submenu and 1
link looping
?>
<TD><?  echo "$submenu"; ?></TD>
<TD><a href="<? echo "$url"; ?> "> <? echo "$element"; ?></a> </TD>
<?

// this doesn't work
if ($menutable_id == $menuid) {
                         ?>
                         <TD><?  echo "equal $submenu"; ?></TD>
                         <?
   // print "both equal";
   //
   // $b = $a;
                      }

?>

Notes:
Loop de loop:
// outer loop   display submenus (when submenu changes display next set
of elements or links from inner loop)   if submenu changes then display
next set of menu links for that submenu
// inner loop display elements or links for that submenu until sub menu
changes


MySQL and PHP4 latest using Linux OS


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to