How to add two values?

Asked

Viewed 70 times

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 so I can also see the page? Other than just what has the value of 1?

3 answers

1

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

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');
    }
}

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 those in 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');
        }
    }
  • THANKS FOR YOUR HELP !

  • For nothing! Kindly, if you can mark as the right question to guide other users who might be in doubt in something like this, I’d appreciate it.

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');
    }
}
  • this I know how to do, but in the same line of if($Row['level'] == '1') you can not do type: if($Row['level'] == '1', '2') ?

  • Ahhhh yes, if($Row['level'] == '1' OR '$Row['level'] == '2')

Browser other questions tagged

You are not signed in. Login or sign up in order to post.