Jump to content

If & Or help


Bradley99

Recommended Posts

I am trying to add something to a menu so that if a person owns a property this menu link will show, but it is only showing if a user owns all of these properties, I use IF, i was wondering if OR would work. This is the code:

 

<?


$bf = mysql_fetch_object(mysql_query("SELECT * FROM bf WHERE owner='$username'"));
$bank = mysql_fetch_object(mysql_query("SELECT * FROM bank WHERE owner='$username'"));
$casino_slots = mysql_fetch_object(mysql_query("SELECT * FROM casinos WHERE owner='$username' AND casino='Slots'"));
$casino_roul = mysql_fetch_object(mysql_query("SELECT * FROM casinos WHERE owner='$username' AND casino='Roulette'"));
$bj = mysql_fetch_object(mysql_query("SELECT * FROM bj WHERE bjowner='$username'"));
$airport = mysql_fetch_object(mysql_query("SELECT * FROM airport WHERE owner='$username'"));



if ($bf->owner == "$username") 
if ($bank->owner == "$username") 
if ($casino_slots->owner == "$username") 
if ($casino_roul->owner == "$username") 
if ($bj->bjowner == "$username") 
if ($airport->owner == "$username") 
echo"  								<tr>
									<td><a class='menuLink' href='myproperties.php' onMouseDown='return false;' target='main'>&#8226;  My Properties</a></td>
									</tr>";   ?>      

Link to comment
https://forums.phpfreaks.com/topic/225525-if-or-help/
Share on other sites

This should work:

 

<?php
...
if ($bf->owner == "$username" ||
    $bank->owner == "$username" ||
    $casino_slots->owner == "$username" ||
    $casino_roul->owner == "$username" ||
    $bj->bjowner == "$username" ||
    $airport->owner == "$username") {
          echo"<tr><td><a class='menuLink' href='myproperties.php' onMouseDown='return false;' target='main'>&#8226;  My Properties</a></td></tr>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/225525-if-or-help/#findComment-1164572
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.