Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Milos Stankovic
Milos Stankovic
15,691 Points

Function get_item_html works fine without $id argument

I removed $id argument from get_item_html($item):

function get_item_html($item) {
    $output = "<li><a href='#'><img src='". $item['img'] ."' alt='" . $item['title'] ."' /><p>View details</p></a></li>";
    return $output;

Also in index.php and catalog.php files that are using this function:

echo get_item_html($catalog[$id]);

The program works fine without it, so I am wondering why it needs to be there?


3 Answers

Hi Milos,

The id is needed for the href attribute on the link. It's currently # as a placeholder but really needs to link to the details.php page.

Updating this link was omitted from the videos but the video linked to below contains an update in the teacher's notes showing how to update the link and why we need the $id.


Milos Stankovic
Milos Stankovic
15,691 Points


Many thanks! Now it makes sense, I updated my product details links.

Thanks again

Alex Forseth
Alex Forseth
8,016 Points

Why is this information not put in the teachers note in the "random fun with arrays" section? Or in an earlier section?