dudejma Posted August 5, 2011 Share Posted August 5, 2011 I have this code: <?php if ($position == 2 || 3) { echo 'There are <b>' . $numApps . '</b> applications.'; echo '<br />'; echo 'There are <b>' . $numLoa . '</b> Leave of Absense requests.'; echo '<br />'; echo 'There are <b>' . $numHub . '</b> hub change requests.'; echo ''; } else {} ?> <?php if ($position == 1 || 4) { echo 'There are <b>' . $numORD . '</b> PIREPs.'; } if ($position == 5) { echo 'There are <b>' . $numDFW . '</b> PIREPs.'; } if ($position == 6) { echo 'There are <b>' . $numJFK . '</b> PIREPs.'; } if ($position == 7) { echo 'There are <b>' . $numLAX . '</b> PIREPs.'; } if ($position == { echo 'There are <b>' . $numMIA . '</b> PIREPs.'; } ?> I only want each of these to show if $position (a session) equals the numbers that I have on there, but it shows the first if statement to anyone. Link to comment https://forums.phpfreaks.com/topic/243945-limiting-what-people-view/ Share on other sites More sharing options...
AyKay47 Posted August 5, 2011 Share Posted August 5, 2011 wrong syntax.. if ($position == 2 || $position == 3) { i know what you are trying to do, but bascially you are checking if $position == 2 correctly, however the || 3 part is checking if 3 returns true, which it always will Link to comment https://forums.phpfreaks.com/topic/243945-limiting-what-people-view/#findComment-1252591 Share on other sites More sharing options...
WebStyles Posted August 5, 2011 Share Posted August 5, 2011 if ($position == 2 || $position == 3) lol. I'm too slow. AyKay47 beat me to it. Link to comment https://forums.phpfreaks.com/topic/243945-limiting-what-people-view/#findComment-1252592 Share on other sites More sharing options...
dudejma Posted August 5, 2011 Author Share Posted August 5, 2011 Ohh, okay. Thanks guys! Link to comment https://forums.phpfreaks.com/topic/243945-limiting-what-people-view/#findComment-1252598 Share on other sites More sharing options...
voip03 Posted August 5, 2011 Share Posted August 5, 2011 Can you use 'switch structure' instead of if else statement? Link to comment https://forums.phpfreaks.com/topic/243945-limiting-what-people-view/#findComment-1252599 Share on other sites More sharing options...
WebStyles Posted August 5, 2011 Share Posted August 5, 2011 or you could do something like this: <?php $outputMessage = array( '1' => 'There are <b>' . $numORD . '</b> PIREPs.'; '2' => 'There are <b>' . $numApps . '</b> applications.<br />There are <b>' . $numLoa . '</b> Leave of Absense requests.<br />There are <b>' . $numHub . '</b> hub change requests.'; '2' => 'There are <b>' . $numApps . '</b> applications.<br />There are <b>' . $numLoa . '</b> Leave of Absense requests.<br />There are <b>' . $numHub . '</b> hub change requests.'; '4' => 'There are <b>' . $numORD . '</b> PIREPs.'; '5' => 'There are <b>' . $numDFW . '</b> PIREPs.'; '6' => 'There are <b>' . $numJFK . '</b> PIREPs.'; '7' => 'There are <b>' . $numLAX . '</b> PIREPs.'; '8' => 'There are <b>' . $numMIA . '</b> PIREPs.'; ); echo $outputMessage[$position]; ?> Link to comment https://forums.phpfreaks.com/topic/243945-limiting-what-people-view/#findComment-1252605 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.