Jump to content

IF Statement, how to include variable for empty


Recommended Posts

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
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.