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 trialAaron Gates
1,573 PointsViewing Details displays the word "Array"
I updated my function to display details as specified in the video and when I refreshed I get the title and table but the content says "Array" instead of the actual category, genre ect. info.
function get_item_html($id, $item){
$output = "<li><a href='details.php?id=" . $id . "'>
<img src='"
. $item["img"] . "'alt='"
. $item["title"] . "' />"
. "<p>View Details</p>"
. "</a></li>";
return $output;
}
~~~<?php
include("Inc/data.php");
include("Inc/functions.php");
if (isset ($_GET['id'])){
$id = $_GET['id'];
if (isset($catalog[$id])){
$item = $catalog[$id];
}
}
if (!isset($item)){
header("location:catalog.php");
exit;
}
$pageTitle = $item["title"];
$section = null;
include("Inc/header.php");?>
<div class="section page">
<div class="wrapper">
<div class="media-picture">
<span>
<img src="<?php echo $item["img"]; ?>" alt="<?php echo $item["title"]; ?>" />
</span>
</div>
<div class="media-details">
<h1><?php echo $item ["title"]; ?></h1>
<table>
<tr>
<th>Category</th>
<td><?php echo["category"];?></td>
</tr>
<tr>
<th>Genre</th>
<td><?php echo["genre"];?></td>
</tr>
<tr>
<th>Format</th>
<td><?php echo["format"];?></td>
</tr>
<tr>
<th>Year</th>
<td><?php echo["year"];?></td>
</tr>
<?php
if (strtolower ($item["category"]) == "books") {
?>
<tr>
<th>Author</th>
<td><?php echo["author"];?></td>
</tr>
<tr>
<th>Publisher</th>
<td><?php echo["publisher"];?></td>
</tr>
<tr>
<th>ISBN</th>
<td><?php echo["isbn"];?></td>
</tr>
<?php }?>
</table>
</div>
</div>
</div>
1 Answer
Patrik Horváth
11,110 Pointsnever saw something like this just try check it and you find your mistake :)
<td><?php echo["category"];?></td>
SPOILER read this only if you cant find your mistake
echo SPACE $VARIABLE["ARRAY_ITEM"];