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 trialNaison Masiyashe
2,736 Pointswhere am i going wrong on this one
i am failing to add more php commands on this code challenge
<?php
$movie = [];
$movie['title'] = "The Empire Strikes Back";
$movie['year'] = "1980";
$movie['director'] = "Irvin Kershner";
$movie['imdb_rating'] = "8.8.";
$movie['imdb_ranking'] = "11.";
?>
<h1><?php echo $movie['title']?><?php echo $movie['year'] ?></h1>
<table>
<tr>
<th>Director</th>
<td> <?php echo $movie['director'] ?>
<?php echo $movie['imdb_rating']?>
<?php echo $movie['imdb_ranking']
?>
</td>
</tr>
<tr>
<th>IMDB Rating</th>
<td>8.5</td>
</tr>
<tr>
<th>IMDB Ranking</th>
<td>53</td>
</tr>
</table>
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHey Naison,
You are definitely on the right track and have all the right code, just not in the right place. The IMDB rating needs to go in the <td> for rating and the IMDB ranking needs to go in the <td> for ranking.
Also, you have a minor typo that will cause the challenge to error out as well. In the original declaration of the "rating" and "ranking" you added a period that was not asked for.
Below is the corrected code. It should makes sense now where the errors were coming from:
<?php
$movie = [];
$movie['title'] = "The Empire Strikes Back";
$movie['year'] = "1980";
$movie['director'] = "Irvin Kershner";
$movie['imdb_rating'] = "8.8";
$movie['imdb_ranking'] = "11";
?>
<h1><?php echo $movie['title']?><?php echo $movie['year']?></h1>
<table>
<tr>
<th>Director</th>
<td><?php echo $movie['director']?></td>
</tr>
<tr>
<th>IMDB Rating</th>
<td><?php echo $movie['imdb_rating']?></td>
</tr>
<tr>
<th>IMDB Ranking</th>
<td><?php echo $movie['imdb_ranking']?></td>
</tr>
</table>
Keep Coding! :)
Kristin Berlehner
26,734 PointsKristin Berlehner
26,734 PointsI think it may have something to do with where you are echoing out your php array values. You need to place <?php echo $movie['imdb_rating']?> where the 8.5 is in the table and move <?php echo $movie['imdb_ranking'] ?> to the correct location in the table as well. You are pulling this data from the array, so it shouldn't be hard coded in the table.