Simple ifelse statement help.

Hello,

I’d like to take the time to thank you for looking into this for me. Though I’m sure its extremely simple I still need some help. I’ve been using Codecademy to learn PHP and I’ve been hung up on this ifelse statement. I’ve checked the code 3 times over to see if I’m missing anything but unable to locate the issue. I return an error on line 5. Thanks for your help ahead of time!

[php]

<?php $items = 6; // Set this to a number greater than 5! if ($items > 5); { echo "You get a 10% discount!"; } elseif ($items = 1) { echo "Sorry, no discount!"; } else { echo "You get a 5% discount!"; } ?>

[/php]

I found my error in line 3! syntax ftw. Thanks for looking into it though ;]

this would be fine, don’t use semicolon after if statement :slight_smile:

[php]<?php
$items = 6; // Set this to a number greater than 5!
if ($items > 5) {
echo “You get a 10% discount!”;
}
elseif ($items == 1) {
echo “Sorry, no discount!”;
}
else {
echo “You get a 5% discount!”;
}
?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service