【发布时间】:2020-06-19 21:56:42
【问题描述】:
我正在我的网站中创建一个以下系统。
现在,当一个用户关注时,假设三个用户,每个用户可以说 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>";
如何修改我的查询,以便每当我的一个关注者回复新消息时,无论我先关注谁,它都会成为显示的第一条消息?
【问题讨论】:
-
你的追随者的最后一条消息是什么,这是足够的信息来猜测
-
我不明白你的评论
-
我的评论告诉您,您必须发布有关您的表格的更多信息。您的树选择看起来可以一举完成。因为所有的表都应该是相关的。
-
好吧,让我修改我的问题@nbk
-
@nbk 请检查编辑,我创建了一个执行完全相同操作的查询。但是现在我将如何让我的查询带来我的任何关注者的最新回复?