Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2016-09-15
3
Medium Priority
?
78 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 2000 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 59

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

722 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