Bradley99 Posted January 24, 2011 Share Posted January 24, 2011 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'>• My Properties</a></td> </tr>"; ?> Link to comment https://forums.phpfreaks.com/topic/225525-if-or-help/ Share on other sites More sharing options...
cyberRobot Posted January 24, 2011 Share Posted January 24, 2011 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'>• My Properties</a></td></tr>"; } ?> Link to comment https://forums.phpfreaks.com/topic/225525-if-or-help/#findComment-1164572 Share on other sites More sharing options...
Bradley99 Posted January 24, 2011 Author Share Posted January 24, 2011 Thanks, i ended up using Else if which worked but your solution is much shorter. Link to comment https://forums.phpfreaks.com/topic/225525-if-or-help/#findComment-1164598 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.