Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Kenneth Warren
2,813 PointsPHP Challenge Problem
Next, we need the flavor selected in the dropdown to be submitted to this process.php file. We need to be able to access it in the “flavor” element of the $_POST array like this: $_POST["flavor"]. What two changes do we need to make to the HTML? (Hint. We need to add two new attributes. The first needs to be added to one existing HTML element, the second needs to be added to a different existing HTML element.)
I can't quite figure either of these out. Can someone show me an example or help me solve this. I read the "Bummer" statement but I've been stuck for days!
<!DOCTYPE html> <html> <head> <title>Ye Olde Ice Cream Shoppe</title> </head> <body>
<p>Your order has been created. What flavor of ice cream would you like to add to it?</p>
<form action="process.php" method="POST">
<label for="flavor">Flavor</label>
<select id="flavor" name="$flavor">
<option value="">— Select —</option>
<option value="Vanilla">Vanilla</option>
<option value="Chocolate">Chocolate</option>
<option value="Strawberry">Strawberry</option>
<option value="Cookie Dough">Cookie Dough</option>
</select>
<input type="submit" value="Update Order">
</form>
</body> </html>
5 Answers

Randy Hoyt
Treehouse Guest TeacherYou are very close. The name
should be flavor
, like this:
<select id="flavor" name="flavor">
You have set it to $flavor
with a dollar sign. The dollar sign is only used before PHP variables.
Does that help?

belindamustoe
5,912 PointsI'm stuck on this one, I can't see what I'm doing wrong, as it's coming up OK on the right hand side!
Q. If the array is NOT empty, the foreach loop will execute. But if it IS empty, we should display a message. Add an else block to the conditional that displays the following message in an HTML paragraph tag: 'There are no flavor recommendations for you.'
A. <?php
$recommendations = array();
?><html>
<body>
<h1>Flavor Recommendations</h1>
<?php
if (!empty($recommendations)){
echo "<ul>";
foreach($recommendations as $flavor) {
echo "<li>" . $flavor . "</li>";
}
echo "</ul>";
}
else {
echo '<p>There are no flavor recommendations for you.</p>';
}
?>
</body>
</html>
error message: Bummer! The array is empty, but I don't see the message indicating that no flavors are found.

Scott Bedard
29,196 Pointsi am having the same issue. I know the code is correct, but it is not showing anything and just keeps saying it is incorrect.

Scott Bedard
29,196 PointsYou need the <p> </p>

John Coughlan
9,414 PointsI had trouble with this one, too. Maybe your problem is with the concatenation this line?
echo "<li>" . $flavor . "</li>";
here's the code that worked for me:
<?php if (!empty($recommendations)) { echo "<ul>"; foreach($recommendations as $flavor) { echo "<li>"; echo $flavor; echo "</li>"; } echo "<ul>"; } else {echo "<p>There are no flavor recommendations for you.</p>";} ?>
good luck!