如何在while循环中找到最后显示的值?

时间:2015-06-24 18:17:53

标签: php mysql pdo

当我通过while循环从数据库中提取信息时,我想检查reasonid是否相同。

<?php
    $sql = "SELECT * FROM notifications WHERE `to`=:my_id ORDER BY id DESC LIMIT 10";
    $query = $db->prepare($sql);
    $query->execute(array(
        ":my_id" => $my_id
    ));
    while ($row = $query->fetchObject()) {
        $from = $row->from;
        $reason = $row->reason;
        $text = $row->text;
        $link_id = $row->link_id;
    }
?>

现在,我想要的是当最后显示的通知和当前显示通知的原因相同时,它们必须显示为一个。

0 个答案:

没有答案