Nested IF statement... challenge
Posted: Wed Jan 11, 2012 2:01 pm
Hi folks… remember when you ‘first’ began to learn PHP… that’s where I’m at now… so the ‘obvious’ may not be so at this point.
I’m struggling with two IF statements… any help would be appreciated.
Originally I was building lines of output that ultimately would be sent via email, the code would loop through ‘values’ and build the “$delivery_info” line based on the contents of $thisFieldValue.; (..the content of which might be something like “ASAP”) … the code below works..
if ($thisFieldName == "Del Date") $delivery_info .= $thisFieldValue.;
..ok… so now I’m trying to make it a ‘bit’ smarter and if the user failed to enter a ‘Delivery Date’… I want to change the value that ends up in $delivery_info with the string “<Field Empty>”. My attempts to add a working sub-IF statement have been less than successful. …my non-working code follows..
if ($thisFieldName == "Del Date") {
if ($thisFieldValue == "") {
$delivery_info .= "<Field Empty>";
} else {
$delivery_info .= $thisFieldValue.;
}
}
If I comment out the inner IF statement… the remaining code works… so I’m shooting myself in the foot somewhere in the inner IF structure.
if ($thisFieldName == "Del Date") {
// if ($thisFieldValue == "") {
// $delivery_info .= "<Field Empty>";
// } else {
// $delivery_info .= $thisFieldValue.;
// }
}
I need a fresh pair of eyes to help me with this please.
Many thanks,
Rasstag
I’m struggling with two IF statements… any help would be appreciated.
Originally I was building lines of output that ultimately would be sent via email, the code would loop through ‘values’ and build the “$delivery_info” line based on the contents of $thisFieldValue.; (..the content of which might be something like “ASAP”) … the code below works..
if ($thisFieldName == "Del Date") $delivery_info .= $thisFieldValue.;
..ok… so now I’m trying to make it a ‘bit’ smarter and if the user failed to enter a ‘Delivery Date’… I want to change the value that ends up in $delivery_info with the string “<Field Empty>”. My attempts to add a working sub-IF statement have been less than successful. …my non-working code follows..
if ($thisFieldName == "Del Date") {
if ($thisFieldValue == "") {
$delivery_info .= "<Field Empty>";
} else {
$delivery_info .= $thisFieldValue.;
}
}
If I comment out the inner IF statement… the remaining code works… so I’m shooting myself in the foot somewhere in the inner IF structure.
if ($thisFieldName == "Del Date") {
// if ($thisFieldValue == "") {
// $delivery_info .= "<Field Empty>";
// } else {
// $delivery_info .= $thisFieldValue.;
// }
}
I need a fresh pair of eyes to help me with this please.
Many thanks,
Rasstag