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


Code Challenge Separation of Concerns

Task 3 of 4

Next, change the $flavors variable in [index.php] to contain the three most popular flavors. Right now, the controller code calls the function get_recent_flavors() in the model code to get the most recent flavors. (Look through [flavors.php] to find a function that returns the most popular flavors.)

My answer below is wrong? Why? The display shows the correct order of flavors.



   $flavors = get_flavors_by_likes($number);

      // VIEW CODE


<h1>Ye Olde Ice Cream Shoppe</h1>

<p>We sell amazing flavors of ice cream.</p>

<h2>Most Popular Flavors</h2>

    foreach ($flavors as $flavor) {
        echo "<li>" . $flavor["name"] . "</li>";

</body> </html>

3 Answers

Yes, that helps. Missed that little detail.

Hemadri Sen
Hemadri Sen
8,621 Points

I am trying to do the same but for some reason it is not working for me. please help

Randy Hoyt
Randy Hoyt
Treehouse Guest Teacher

The instructions say that the page should show the three most popular flavors. When I preview the page with your code, it looks like it is showing six flavors.

Does that help?

Hemadri Sen
Hemadri Sen
8,621 Points

I am lost in this one. I am not sure how should i do it.