【发布时间】:2023-03-27 06:50:01
【问题描述】:
我在messages.php上创建了消息系统,我想明智地显示消息对话,应该显示最后一条消息,但不知道查询,因为我是php新手,这里是数据库信息
table:conversation_chat table2:chat conversation_id: primary unique id: primary unique from: conversation_id: to: from_user: time: to_user: message: subject:
如果有人可以帮助我,请
<?php
$req3 = mysql_query("SELECT * FROM `conversation_chat` WHERE
`user_to`='$userid1'");
$hy= mysql_fetch_array($req3);
$convo = $hy['conversation_id'];
if(mysql_num_rows($req3)!=0){
$req4 = mysql_query("SELECT * FROM `chat` WHERE `to`='$userid1' AND
`conversation_id`='$convo'");
while($dn1 = mysql_fetch_array($req4))
{
?>
<td><img alt="example image" src="avatar.png"> <a
href="read?id=<?php echo $dn1['id']; ?>"><?php echo
htmlentities($dn1['from'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td><span class="label vd_bg-green append-icon">
<?php
echo $dn1['subject']; ?></span></td>
<td style="width:80px" class="text-right">
<strong><?php echo timeAgo($dn1['time']); ?></strong></td><td
style="width:80px" class="text-right">
<?php echo '<a
href="mdelete.php?id='. $dn1['id'] .'">Delete</a>'; ?></td>
</tr>
<?php
}}else{ echo "No new messages";}
?>
【问题讨论】:
-
所以你想有效地扭转谈话?
-
我希望在messages.php上的对话中显示最后一条消息,并附上他的名字和消息