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! While you're at it, check out some resources Treehouse students have shared here.
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
Warren Johnson
6,870 PointsCode Challenge: Adding Search: Controller & View - Accounting for Empty Results
Can someone tell me if I am doing this conditional right?? Am I initiating it in the right place in the code? Something tells me, I'm not...
My Code:
<?php
$recommendations = array();
?><html>
**This is where I attempted to instantiate the conditionalAlso, are there (2) conditionals req'd for this challenge???****
<?php if (!empty($flavors)) { <body>
<h1>Flavor Recommendations</h1>
<ul> <?php foreach($recommendations as $flavor) { ?> <li><?php echo $flavor; ?></li> <?php } ?> </ul> ;?> } </body> </html>
1 Answer
Dan Gorgone
Treehouse Guest TeacherHi Warren, I'd suggest tagging your post with the appropriate course name to make sure someone sees it, e.g. php, ios, android, and so on.
Warren Johnson
6,870 PointsThanks Dan for the suggestion....Actually, this post has been sitting out there since the middle of last week...I have since figured it out. Thanks, once again!
Warren Johnson
6,870 PointsWarren Johnson
6,870 PointsUPDATED 7/4/13
<?php
$recommendations = array();This is where I attempted to instantiate the conditional if ($flavors != "") { if (!empty($recommendations)) {
echo '<html>'; echo '<body>';
echo '<h1>Flavor Recommendations</h1>';
echo '<ul>'; foreach($recommendations as $flavor) { ?> <li><?php echo $flavor; ?></li> }; ?> echo '</ul>';
echo '</html>'; echo '</body>'; } } ?>