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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
dudejma Posted August 5, 2011 Author Share Posted August 5, 2011 Ohh, okay. Thanks guys! Quote Link to comment 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? Quote Link to comment 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]; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.