News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Need help with if statements for 3 options

Started by shadav, March 21, 2021, 06:39:02 PM

Previous topic - Next topic

shadav

so I have 3 options and I can't quite get it to work
2 options worked just fine but when I decided to try to add a 3rd option it fails, than again I don't know what I'm doing  :laugh:

so I'm trying to make a coupon directory

this works, if they filled used a url and coupon description show the first statement, if they used a coupon code and description then show the second statement
if (!empty($context['custom_fields']['3_COUPON_URL']))
    echo'
<tr class="odd"><td><a href="'.$context['custom_fields']['3_COUPON_URL'].'">'.$context['custom_fields']['1_COUPON_DESCRIPTION'].'</a></td><td>No Code Need, Click On The Coupon</td></tr>';
else
if (empty($context['custom_fields']['3_COUPON_URL']))
echo '
<tr class="odd"><td>'.$context['custom_fields']['1_COUPON_DESCRIPTION'].'</td><td>'.$context['custom_fields']['2_COUPON_CODE'].'</td></tr>';


but I would like a 3rd option that if they used both a url and code to display it, however it's not working
if (!empty($context['custom_fields']['3_COUPON_URL'])  && empty($context['custom_fields']['2_COUPON_CODE']))
    echo'
<tr class="odd"><td><a href="'.$context['custom_fields']['3_COUPON_URL'].'">'.$context['custom_fields']['1_COUPON_DESCRIPTION'].'</a></td><td>No Code Need, Click On The Coupon</td></tr>';
else
if (!empty($context['custom_fields']['3_COUPON_URL']) && !empty($context['custom_fields']['2_COUPON_CODE']))
echo '
<tr class="odd"><td><a href="'.$context['custom_fields']['3_COUPON_URL'].'">'.$context['custom_fields']['1_COUPON_DESCRIPTION'].'</td><td>'.$context['custom_fields']['2_COUPON_CODE'].'</td></tr>';
else
if (empty($context['custom_fields']['3_COUPON_URL']))
echo '
<tr class="odd"><td><a href="'.$context['custom_fields']['3_COUPON_URL'].'">'.$context['custom_fields']['1_COUPON_DESCRIPTION'].'</td><td>'.$context['custom_fields']['2_COUPON_CODE'].'</td></tr>';

d3vcho

Which one is not working with the 3 options chunk of code?
"Greeting Death as an old friend, they departed this life as equals"

shadav

#2
neverminded, ignore me...i'm an idiot....
:laugh:

sleep deprived

Shambles


Advertisement: