0

I am trying to add a review system into my site but having trouble echoing current reviews of recipes. So if I review recipe ID 1 I would like reviews of that specific ID to be shown.

Problem is when I try and echo the review_comment column of my review table (shown in image) nothing happens on my site, it is just blank space.

Code:

      <?php

      $query = "SELECT * FROM reviews WHERE recipe_id = :id";
      $pdo = $DBH->prepare($query);
      $pdo->bindParam(':id', $id);
      $pdo->execute();

      $review_data = $pdo->fetch(PDO::FETCH_ASSOC);

      ?>
<div>
  <h2 align="center"> Reviews </h2>

  <?php echo $review_data['review_comment']; ?>


</div>

The recipe_id = :id code is received from the url and works fine

review table

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345

0 Answers0