根据变量显示结果


Display results according to a variable

我试图根据变量显示一个表,但在视图中出现错误
这是获取结果的数据库函数,我传入值$series

function getReviews($series) {
    global $db;
    $query = 'SELECT review FROM reviews
              where series = :series';
    $statement = $db->prepare($query);
    $statement->bindValue(':series', $series);
    $statement->execute();
    $reviews = $statement->fetchAll();
    $statement->closeCursor();    
    return $reviews;
}

这是的视图

<div id="reviews" class="tab-pane fade">
    <h3>Reviews</h3>
    <table>
        <thead>
            <tr>
                <th>Review</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($reviews as $review) : ?>
                <tr>
                    <td><?php echo $reviews['review']; ?></td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
</div>

我得到了一些结果,因为$series = 1下有3条评论,但它们没有显示

注意:未定义的索引:在C:''examplep''htdocs''WEBCA5LP''view''main.php中的第52行中查看

注意:未定义的索引:在C:''examplep''htdocs''WEBCA5LP''view''main.php中的第52行中查看

注意:未定义的索引:在C:''examplep''htdocs''WEBCA5LP''view''main.php中的第52行中查看

你在回应错误的东西-$review而不是$reviews

<?php foreach ($reviews as $review) : ?>
  <tr>
    <td><?php echo $review['review']; ?></td>
  </tr>
<?php endforeach; ?>