Solved

What is the most practical way to display items based in each user level?

Posted on 2016-09-15
3
70 Views
Last Modified: 2016-09-16
Hello,

I'm trying to figure out how to build a menu that will show more or less elements based on each user level in PHP.

I'm currently naming user levels in the DB as "Admin", "User", "Special" and so on. What I need is for the Admin to see all elements, the user to see some elements and so on. I could do lots of IF statements but maybe there's a quick way to do it in a function or something?

Thanks in advance!
0
Comment
Question by:Cesar Aracena
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 500 total points
ID: 41800390
An alternative to creating a menu with many if statements is to create 3 menus in 3 separate files, let's say menu_admin.php, menu_user.php and menu_special.php, then include the right file depending on the logged user level.
0
 
LVL 6

Author Closing Comment

by:Cesar Aracena
ID: 41800419
Didn't thought it would make much sense but now that I read your response it totally made sense!
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 41801266
Usually menu systems like this are created dynamically. You have a data structure in which the menu items and user access are stored which is used to construct the menu - the data structure is usually (but does not have to be) sourced from a database query that joins available menu items to users based on an access_rights table linking users to menu items.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question