Menu Template included in every page????

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

User avatar
Joan Garnet
Moderator
Moderator
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars
Contact:

Postby Joan Garnet » Thu Nov 21, 2002 3:54 am

Well, I think it goes like this:
You have your mysql table called menu with id and name_menu of menu.
Then you have another table called submenus with id, id_menu (which corresponds whith the id of the menu above) and the name_submenu of the submenu.

Then to output this data you gotta make a query like this:

Code: Select all

<?php
$login="blablabla";
$pass="passpasspass";
$server="localhost";
$bbdd="my_database_name";
$db=mysql_connect($server,$login,$pass);    
mysql_select_db($bbdd,$db);
$sql="select * from submenu where id_menu = '$my_var'";//$my_var is the $HTTP_GET_VARS corresponding with the id of the menu clicked by the user
$result = mysql_query ($sql,$db);
while ($row = mysql_fetch_array ($result)) {
   echo "<a href='".$row["name_submenu"].".php'>".$row["name_submenu"]."</a>&nbsp;&nbsp;";//this will output as many links as submenus has the clicked menu, and each link will take you to a page called sub_menu_name.php
}
?>


Maybe I talked too much...
You just gotta swallow it now
:)

Return to “PHP coding => General”

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest