php - How to show menu selected a different style than others for a dynamically created ul li menu -
In my php project I have a dynamic menu, i.e. menu change based on logged users ... menu item db Now I want to show the selected menu in a different style ... that is, if I click on the User Manager, the menu user should be highlighted. For this, create_user and modify_user should be highlighted ... < / P>
& lt; Ul & gt; & Lt; Li & gt; & Lt; A href = "dashboard.php" & gt; Dashboard & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "user_manager.php" & gt; User manager & lt; / A & gt; & Lt; / Li & gt; & Lt; & Lt; Li & gt; & Lt; A href = "category.php" & gt; Category & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; How can I implement it? Any help would be appreciated ....: -
The easy way is, the user group naming style in your CSS.
& lt; Style & gt; .admin {} Manager {} .user {} & lt; / Style & gt; And using PHP to echo the user group in your menu
& lt; Ul class = "& lt;? = $ _ Session ['user_group']? & Gt;" & gt; By & lt;? If ($ _ session ['user_group'] == 'admin') {? & Gt; & Lt; Li & gt; & Lt; A href '#' & gt; Create User & lt; / A & gt; & Lt; / Li & gt; & Lt;? }? & Gt; & Lt; Li & gt; & Lt; A href = '#' & gt; Logout & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt;
Comments
Post a Comment