I'm working on a project where a user will login and it only shows records if the rep column is their name. I know there's a ton of ways to do this but the easiest way for me is to use If statements with sessions
if($_SESSION['account_type'] == 'Rep') {
$sql = "SELECT * FROM `employee` WHERE rep='".$_SESSION['name']."' ";
} elseif ($_SESSION['account_type'] == 'Manager') {
$sql = "SELECT * FROM `employee` WHERE Manager='".$_SESSION['name']."' ";
} elseif ($_SESSION['account_type'] == 'Regional') {
$sql = "SELECT * FROM `employee` WHERE Region='".$_SESSION['regional']."' ";
} elseif ($_SESSION['account_type'] == 'Other') {
$sql = "SELECT * FROM `employee` ";
} else {
echo 'no records found';
}
If your account type is a rep, show just records with your name. If your account type is manager, show records where the manager record has your name, etc etc.
For some reason, I'm not getting any records back at all; its blank.
If I change it to just:
$sql = "SELECT * FROM `employee` WHERE rep='".$_SESSION['name']."' ";
I get records back where it has the users name in the rep column; which is great but i need the if statements to work.
Any ideas?
UPDATE
Syntax error - thanks!