当我通过while循环从数据库中提取信息时,我想检查reason
和id
是否相同。
<?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;
}
?>
现在,我想要的是当最后显示的通知和当前显示通知的原因相同时,它们必须显示为一个。