Jump to content


Photo

Dynamic menus


  • Please log in to reply
1 reply to this topic

#1 jzdexta

jzdexta
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 06 April 2006 - 04:18 PM

Was wondering if i could create dynamic menus based in user logn details?
This is supposed to be an intra-net based site where members of the organisation can log their data periodically from any machine within the organisation though with hopes of extendng it to internet logging of data.
Anyone with ideas of what to do for the time being the menu is static
Thanx in advance

#2 bbaker

bbaker
  • Members
  • PipPipPip
  • Advanced Member
  • 127 posts
  • LocationNY

Posted 06 April 2006 - 05:03 PM

you could base the menu's on user level (i assume this is why you want different menus). you could set up your database menu sort of like this:

menu_title | menu_url | user_level
----------------------------------------------
Home | index.php | 0
Admin | admin.php | 1
Contact | contact.php | 0

where level 0 is basically anyone & level 1 is admin level (obviously)

You'd need a level field in your user database as well. When the user logins in, check that user's level & set a session variable for the user's level. Then when you get the menu make sure your query selects the info based on the user level.

mysql_query("SELECT * FROM menu_table WHERE user_level = '".$_SESSION['user_level']."' OR user_level = '0'") or die(mysql_error());

This query will always show menu items where user_level is 0 & will ONLY show level 1 items if the session level is 1.

Hope this helps





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users