Hello everyone,
I have been trying to get this piece of coding to work! It contains multiple if statements and has just sent my mind spinning. I have an error code and cant seem to get past it!
What im trying to achieve is to basically check if the username is access level 1.
If the user is access level 1 then I want it to print the code and stop there!
If the user isnt access level 1 then I want it to go onto access level 2 and check is the user is level 2! If they are then it prints the code and if not then it checks to see if they are access level 3 and so on.
Its very complicated and has stumped me! The code is working ok at the moment but because my users can have multiple jobs and access levels the code basically checks for ALL jobs and then prints the code for each position that is true! This is obviously pointless and I want to make it so it only prints one copy of level 1 access if member is level 1 ...or to print ONLY one copy is member is level 2 access and so on.
Any Ideas?
while($row = mysql_fetch_array($find_access))
{
//Show content for level ONE
if ( ($row[lobby]== 1) AND ($row[user_id] == $username))
{
echo "show content gere for access level 1";
$counter++;
//If no CONTENT for level ONE then show content for level TWO
if ( !($row[lobby]== 1) AND ($row[user_id] == $username))
{
//Show content for level TWO
if ( ($row[lobby]== 2) AND ($row[user_id] == $username))
{
echo "show content gere for access level 2";
$counter++;
}
}
//If no CONTENT for level TWO then show content for level THREE
if ( !($row[lobby]== 2) AND ($row[user_id] == $username))
{
//Show content for level THREE
if ( ($row[lobby]== 3) AND ($row[user_id] == $username))
{
echo "show content gere for access level 3";
$counter++;
}
}
//If no CONTENT for level THREE then show content for level THREE
if ( !($row[lobby]== 3) AND ($row[user_id] == $username))
{
//Show content for level FOUR
if ( ($row[lobby]== 4) AND ($row[user_id] == $username))
{
echo "show content gere for access level 4";
$counter++;
}
}
//If no CONTENT for level FOUR then show content for level ZERO
if ( !($row[lobby]== 4) AND ($row[user_id] == $username))
{
//Show content for level FOUR
if ( ($row[lobby]== 0) AND ($row[user_id] == $username))
{
echo "show content gere for access level 0";
$counter++;
}
}
else
{
echo "<p><br><p><p><center>This page is a restrcited area. You do not have access!";
}
}