How to add two values?

1
while($row = mysql_fetch_assoc($result))
{
    if($row['level'] == '1') //COMO ADICIONO PARA OUTRO NIVEL CONSEGUIR VER ESTA PAGINA?
    {
        echo('OLAAAA');
    }
    else
    {
        echo('NAO TENS ACESSO A ESTA PAGINA');
    }
}

How do I add the other user with another value to also be able to see the page? Without being only what has the value of 1 ?

    
asked by anonymous 13.01.2015 / 19:26

3 answers

1

If it is for him to see the same page as the user with level 1 use the code below:

while($row = mysql_fetch_assoc($result))
{
    if($row['level'] == '**1**' || $row['level'] == '**2**' || $row['level'] == '**3**')
    {
        echo('OLAAAA');
    }
    else
    {
        echo('NAO TENS ACESSO A ESTA PAGINA');
    }
}

If it is for him to see a page different from who is at level 1 use:

while($row = mysql_fetch_assoc($result))
    {
        if($row['level'] == '**1**')
        {
            echo 'OLAAAA';
        }
       else if($row['level'] == '**2**')
       {
            echo 'Level 2';
       }
        else
        {
            echo('NAO TENS ACESSO A ESTA PAGINA');
        }
    }
    
13.01.2015 / 19:33
1

You only need to allow another level within the IF, with the || operator. Something like this:

while($row = mysql_fetch_assoc($result))
{
    if($row['level'] == '1' || $row['level'] == '2') // Agora nível 1 e 2 podem ver.
    {
        echo('OLAAAA');
    }
    else
    {
        echo('NAO TENS ACESSO A ESTA PAGINA');
    }
}
    
13.01.2015 / 19:32
0
    while($row = mysql_fetch_assoc($result))
{
    if($row['level'] == '**1**')
    {
        echo('OLAAAA');
    } elseif ($row['level'] == '**2**') {
        echo('OLAAAA USER 2');
}
    else
    {
        echo('NAO TENS ACESSO A ESTA PAGINA');
    }
}
    
13.01.2015 / 19:29