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
Nested IF statement... challenge
Moderator: General Moderators
Re: Nested IF statement... challenge
You have a period at the end of this line:
Another method:
-Greg
Code: Select all
$delivery_info .= $thisFieldValue.;
^Code: Select all
if ($thisFieldName == "Del Date") {
$delivery_info .= ($thisFieldValue == "") ? "<Field Empty>" : $thisFieldValue;
}
Re: Nested IF statement... challenge
... thank you SO much twinedev… sure enough that little ‘punctuation’ was making it not work.. (and making me crazy).
I owe you a cold one when next we meet at the tavern!
Be safe my friend.
Rasstag
I owe you a cold one when next we meet at the tavern!
Be safe my friend.
Rasstag