I am validating a menu according to the type of user, for example the fields that I validate are these:
So the code I use to display by user is this
<?php if($tipo_usuario == 5) { ?>
//Aca dentro coloco el menu segun el tipo de usuario, por ejemplo este solo tiene 3 menus que son Cerrar sesion, cambiar contraseña y registrar asistencia y asi varia segun el usuario
<?php } ?>
what I want to do is add more conditions to this validation
<?php if($tipo_usuario == 5) { ?>
For example, this is the users table, so it validates the type of user but I added 2 new fields which are assigned zone and assigned_sector
And what I want is that for example if the user is type_user=5 , zone_assigned=1, sector_assigned=1 to show me a menu
if the user is type_user=5 , zone_assigned=1, sector_assigned=2 that shows me another menu and so on
I don't know how to add the validation of the assigned_zone and assigned_sector fields to this code
<?php if($tipo_usuario == 5) { ?>
You can use the "&&" or "and" operator (depending on the version of php you are using).
Example:
Or if you have a version greater than 7.3
I hope this helps you.
The suggestion is to use a logical operator since two conditions are met in both: user_type=5 and assigned_zone=1. The && is that logical operator that links two conditions as both have to be true for it to be valid.
Then, inside the if, you place a switch case that evaluates the variable $sector_assigned.