Andrew R Posted November 25, 2006 Share Posted November 25, 2006 Hi, I was wondering why this script (below) isn't working. For example, when the inputs, day, aircraft, departure, arrival = Any, why does the echo, "Day, Aircraft, Departure, Arrival = Any" not display?[code]$day=$_POST["day"];$aircraft=$_POST["aircraft"];$departure=$_POST["departure"];$arrival=$_POST["arrival"];if ($day == "Any") {echo 'Day = Any';}elseif ($aircraft == "Any") {echo 'Aircraft = Any';}elseif ($departure == "Any") {echo 'Departure = Any';}elseif ($arrival == "Any") {echo 'Arrival = Any';}elseif ($day && $aircraft && $departure && $arrival == "Any") {echo 'Day, Aircraft, Departure, Arrival = Any';}[/code]Cheers Quote Link to comment https://forums.phpfreaks.com/topic/28467-if-else-script-help/ Share on other sites More sharing options...
Philip Posted November 25, 2006 Share Posted November 25, 2006 This should work :)[code]<?php$day=$_POST["day"];$aircraft=$_POST["aircraft"];$departure=$_POST["departure"];$arrival=$_POST["arrival"];if ($day == "Any") {echo 'Day = Any';}elseif ($aircraft == "Any") {echo 'Aircraft = Any';}elseif ($departure == "Any") {echo 'Departure = Any';}elseif ($arrival == "Any") {echo 'Arrival = Any';}elseif ($day == "Any" && $aircraft == "Any" && $departure == "Any" && $arrival == "Any") {echo 'Day, Aircraft, Departure, Arrival = Any';}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/28467-if-else-script-help/#findComment-130259 Share on other sites More sharing options...
Andrew R Posted November 25, 2006 Author Share Posted November 25, 2006 Cheers :), although its still not working. Somehow I need a script that if Day does = Any it will not just pick the first if statement that applies to Day = Any. I need it to search through all the statements to find the right one. So if all the values (day, aircraft, departure, arrival) = Any it will find that if statement.Cheers Quote Link to comment https://forums.phpfreaks.com/topic/28467-if-else-script-help/#findComment-130268 Share on other sites More sharing options...
Philip Posted November 25, 2006 Share Posted November 25, 2006 Try switching the if they all = any and the first expression you had. This way it checks to see if they all = any first, then if it doesn't it will run through the rest of them.[code]<?php$day=$_POST["day"];$aircraft=$_POST["aircraft"];$departure=$_POST["departure"];$arrival=$_POST["arrival"];if ($day == "Any" && $aircraft == "Any" && $departure == "Any" && $arrival == "Any") {echo 'Day, Aircraft, Departure, Arrival = Any';}elseif ($day == "Any") {echo 'Day = Any';}elseif ($aircraft == "Any") {echo 'Aircraft = Any';}elseif ($departure == "Any") {echo 'Departure = Any';}elseif ($arrival == "Any") {echo 'Arrival = Any';}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/28467-if-else-script-help/#findComment-130270 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.