could anyone tell me the format for the php if and statement ie
if($userdata['user_rank']==1 and $userdata['user_rank']==2)
and the php if or statement ie
if($userdata['user_rank']==1 or $userdata['user_rank']==2)
thanx
if and or
Moderator: General Moderators
You've already got it!
Those are correct, but are usually just used alternatively to:
Code: Select all
<?php
if($userdata['user_rank'] == 1 && $userdata['user_rank'] == 2)
{
//dostuff
}
if($userdata['user_rank'] == 1 || $userdata['user_rank'] == 2)
{
//dostuff
}
?>i dont see anythign wrong with that cept that the "and" needs to be && and the "or" should be ||... just operators.
To keep the code clean, atleast its how I do it is i assign the row results as a var, IE:
Just now you can use $exam instead of typing out the row call.
:/edit - man duff thats twice you got me today, your fired. =]
To keep the code clean, atleast its how I do it is i assign the row results as a var, IE:
Code: Select all
<?php
$sql = "SELECT * from whatever";
$quer = mysql_query($sql);
$row = mysql_fetch_array($quer);
$exam = $row["user"];
?>:/edit - man duff thats twice you got me today, your fired. =]
Using "and" and "or" is perfectly acceptable. Only difference is [php_man]http://uk.php.net/manual/en/language.op ... precedence[/php_man]tim wrote:i dont see anythign wrong with that cept that the "and" needs to be && and the "or" should be ||... just operators.
Last edited by McGruff on Tue Aug 09, 2005 5:39 pm, edited 1 time in total.