jasper1106 Posted August 8, 2010 Share Posted August 8, 2010 Hello all, I am a beginner at PHP and trying to form an IF statement, I'm running into a problem which I cannot seem to solve. Due to my lack of syntax knowledge I would appreciate if someone could point me in the right direction. The combo variables are sent to this page through a form and defined as these variables at the top of the page. e.g $combo0 = $_POST["combo0"]; When the results are displayed any form field which was left blank or empty I want to show "N/A" if data is detected in being sent through the form I then want the "Else" statement to take affect. Currently when I run the below statement N/A is echoed despite if data was sent through the form fields or not.... if (empty($scrap)) { echo "<h3>Submitted Scrap Results</h3> No scrap parts were booked off"; } elseif (empty($combo0) || empty($combo1) || empty($combo2) || empty($combo3) || empty($combo4)) { echo "N/A"; } else { echo "<h3>Submitted Scrap Results</h3> <b>Reason:</b> " .$combo0." - ".$combo1." - ".$combo2." - ".$combo3." - ".$combo4." <br /> <b>on machine</b> " .$mid. " - <b>No. Scrap</b> " .$noscrap. ""; } Anyone any ideas? Link to comment https://forums.phpfreaks.com/topic/210094-if-statement-how-to-include-variable-for-empty/ Share on other sites More sharing options...
RussellReal Posted August 8, 2010 Share Posted August 8, 2010 are all the fields named and assigned appropriately? Link to comment https://forums.phpfreaks.com/topic/210094-if-statement-how-to-include-variable-for-empty/#findComment-1096469 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.