我正在我的网站上创建一个以下系统。
现在,当用户关注时,可以说三个用户,每个用户可以说 3-4 条消息。
当其中一个用户回复已发送给他的新消息时,我希望此消息成为要显示的顶部消息。
我现在得到的是,即使是新消息,消息也会为每个用户成堆。
这是我的 php 和查询:
$uid=$_SESSION['active_user_id'];
$usersFollowingsQuery = $db->prepare("SELECT mr.*, f.* FROM messages_reply mr INNER JOIN follow f on mr.from_id = f.followed_id
WHERE follower_id = ? ORDER BY follow_id desc");
$usersFollowingsQuery->bindValue(1,$uid);
$usersFollowingsQuery->execute();
if($usersFollowingsQuery->rowCount()==0){
echo"<div class ='forgot'>Follow users to find their content here</div>";
}
else{
echo"<div class ='forgot'>This is your feed</div>";
while($row3 =$usersFollowingsQuery->fetch()){
$followed_id = $row3['followed_id'];
$usersPicQuery = $db->prepare("SELECT * FROM users WHERE id=?");
$usersPicQuery->bindValue(1,$followed_id);
$usersPicQuery->execute();
$row2 = $usersPicQuery->fetch();
$d=$row['date'];
?>
<div Class="inside-card" style="width:95%; margin-top:24px;"
<td>
<div class="msg-body">
</a>
</img>
<p style="font-size:16px; color:#696969"><?php echo $row3['question']; ?></p>
<div class="msg-action">
<div>
<a href=<?php echo "'q=" . $row2['username'] . "'" ;?>> <img src=<?php echo "'" . $row2['picture'] . "'";?> width="32px" height="32px" >
<p ><?php echo "" . $row2['username'] . "" ;?></p></a>
<span class="msg-icon" ><?php echo timeAgo($d); ?></span>
</div>
<p ><?php echo $row3['answer']; ?></p>
</div>
</td>
</tr>
</div>
<?php
}
}
echo"</div>";
我如何修改我的查询,以便每当我的一个关注者回复一条新消息时,无论我首先关注谁,它都会成为显示的第一条消息?
我解决了问题,只需要添加 order by date desc
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句