Jump to content

Dynamic menus


jzdexta

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.