Jump to content

Archived

This topic is now archived and is closed to further replies.

jzdexta

Dynamic menus

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.