Hi, I am in a pickle over how to do this.
I am trying to create 2 menu's for a customers site (1 vert, 1 horiz) both of which can be altered from an admin section to add new categories or sub menu's.
First question is, would I be best setting up a single MySQL table as:
menu_id - Primary Key auto increment
menu_name - Displaying menu title
menu_link - link to page
menu_sub_id - Foreign key linked back to menu_id
or 2 seperate Tables using a foreign key to connect them.
Second question is, how can I display these. I've been trying all sorts of methods, such as:
which will display the main menu perfectly fine.
But I can't for the love of god get the submenu's to display. I've been trying a 'foreach' statement, but I'm relatively new to that, and just can't figure out what I'm doing wrong. This is what I've been trying:
The verticle menu also has to go 2 levels deep, ie:
Title1
->Submenu1
->Submenua
->Submenu2
->Submenub
Title2 etc
Any help on this would be greatly appreciated, not sure if it's just tiredness that's not letting me see the light on this one, but I'm determined to crack this before going any further with the site development.
Thanks in advance
I am trying to create 2 menu's for a customers site (1 vert, 1 horiz) both of which can be altered from an admin section to add new categories or sub menu's.
First question is, would I be best setting up a single MySQL table as:
menu_id - Primary Key auto increment
menu_name - Displaying menu title
menu_link - link to page
menu_sub_id - Foreign key linked back to menu_id
or 2 seperate Tables using a foreign key to connect them.
Second question is, how can I display these. I've been trying all sorts of methods, such as:
Code:
<ul>
<?php do { ?>
<li><a href="<?php echo $row_Top_Menu['menu_link']; ?>"><?php echo $row_Top_Menu['menu_name']; ?></a>
<?php } while ($row_Top_Menu = mysql_fetch_assoc($Top_Menu)); ?></li>
</ul>
But I can't for the love of god get the submenu's to display. I've been trying a 'foreach' statement, but I'm relatively new to that, and just can't figure out what I'm doing wrong. This is what I've been trying:
Code:
<ul>
<?php do { ?>
<li><a href="<?php echo $row_Top_Menu['menu_link']; ?>"><?php echo $row_Top_Menu['menu_name']; ?></a>
<ul>
<?php
foreach ($row_Top_Menu['menu_id'] AS $subs) {
mysql_select_db($database_gce_db, $gce_db);
$query_Top_Sub_Menu = "SELECT * FROM cgc_menu WHERE menu_position = 1 AND menu_parent_id = $subs";
$Top_Sub_Menu = mysql_query($query_Top_Sub_Menu, $gce_db) or die(mysql_error());
$row_Top_Sub_Menu = mysql_fetch_assoc($Top_Sub_Menu);
$totalRows_Top_Sub_Menu = mysql_num_rows($Top_Sub_Menu);
echo "<li>".$row_Top_Sub_Menu['menu_name']."</li>";
}
?>
</ul>
</li>
<?php } while ($row_Top_Menu = mysql_fetch_assoc($Top_Menu)); ?>
</ul>
The verticle menu also has to go 2 levels deep, ie:
Title1
->Submenu1
->Submenua
->Submenu2
->Submenub
Title2 etc
Any help on this would be greatly appreciated, not sure if it's just tiredness that's not letting me see the light on this one, but I'm determined to crack this before going any further with the site development.
Thanks in advance