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

PHP Integrating PHP with Databases Using Relational Tables Fetching Many Relationships

Software Singh
Software Singh
7,123 Points

stuck! can't see results

when i use "var_dump()" function to see whats happening ,nothing appears on preview. Eve when i echo something no i dont get any results in preview tab.

and i am not able to understand what is the problem with my code. And what i am actually supposed to do in this task

index.php
<?php

include "helper.php";

while($row = $results->fetch(PDO::FETCH_ASSOC)){

  $id = $row['genre_id'];
  $genre = $row['genre'];

 $item['genres'] = array( $id => $genre);

}
/*
 * helper contains the following variables:
 * $item is an array that contains details about the library item
 * $results is a PDOstatement object with our genre results.
 */
Kent Γ…svang
Kent Γ…svang
18,823 Points

I can't identify anything other than a missing closure for your php-tag. " ?> ". Could that be it ?

Software Singh
Software Singh
7,123 Points

thanks kent Asvang but that was not the issue

actually issue was $item['genres'][$row['id']] = $row['genre'];

anyways i could not understand the actual structure of $item array