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

Lars Hansen
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Lars Hansen
Front End Web Development Techdegree Graduate 19,694 Points

Catalog Page just refreshes when trying to view details.php

Hello,

Whenever I either click a catalog item or writes out the URL manually, the catalog page just refreshes instead of showing me the details of the catalog item.

I think Something is wrong with my functions.php, but can not find it. Here is my functions .php:

<?php

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;

}


function array_category($catalog,$category) {
 $output = array();

  foreach ($catalog as $id => $item) {
    if ($category == null OR strtolower($category) == strtolower($item["category"])) : 
        $sort = $item["title"];
        $sort = ltrim($sort, "The ");
        $sort = ltrim($sort, "A ");
        $sort = ltrim($sort, "An ");
        $output[$id] = $sort; 
    endif;
  }
  asort($output);
  return array_keys($output);
}

And my Details.php

<?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 = $iten["title"];
$section = null;
include('inc/header.php'); 
?>

<div clas="section page">
  <div class="wrapper">

    <div class="media-picture">
      <span><img src="<?php echo $item["img"]; ?>" alt="<?php echo $item["title"] ?>" /></span>
     </div>

  </div>
  <div class="media-details">
    <h1><?php echo $item["title"] ?></h1>
    <table>
      <tr>
        <th>Category</th>
        <td><?php echo $item["category"]?></td>
      </tr>
      <tr>
        <th>Genre</th>
        <td><?php echo $item["genre"]?></td>
      </tr>
      <tr>
        <th>>Format</th>
        <td><?php echo $item["format"]?></td>
      </tr>
      <tr>
        <th>Year</th>
        <td><?php echo $item["year"]?></td>
      </tr>
    <?php
      if (strolower($item["category"]) == "books") {
    ?>
      <tr>
          <th>Authors</th>
          <td><?php echo implode(", ", $item["authors"]); ?></td>
      </tr>
      <tr>
          <th>Publishers</th>
          <td><?php echo $item["publisher"]; ?></td>
      </tr>
      <tr>
          <th>ISBN</th>
          <td><?php echo $item["isbn"]; ?></td>
      </tr>

     <?php } ?>


    </table>
  </div>
</div>

<?php
  include("footer.php");
  ?>

Thank you.