我是php的新手,我想知道如何查看消息
这是我的代码
$idto = $_GET['id'];
$query2 = mysql_query("select * from users where id =".$idto." ");
$row2 = mysql_fetch_assoc($query2);
echo "<b><font size='6' face='Comic Sans MS'><center>".$row2['firstname']."</center></font></b><br><br>";
$query2 = mysql_query("select * from message where id_from =".$idto." and id_to =". $_SESSION['id']." ORDER BY id");
$query1 = mysql_query("select * from message where id_to =".$idto." and id_from =". $_SESSION['id']." ORDER BY id");
我选择user1&amp;发送的消息用户2,但我不知道如何正确查看它们 当我使用这个
while ($row = mysql_fetch_assoc($query2) )
{
echo'<fieldset style="width:250" align="center">';
echo"<legend><b>".$row2['firstname']."</b></legend>";
echo $row['message'];
echo "<br>";
echo $row['date'];
echo"<hr>";
echo"</fieldset>";
}
while ($row1 = mysql_fetch_assoc($query1) )
{
echo'<fieldset style="width:250" align="center">';
echo"<legend><b>".$_SESSION['firstname']."</b></legend>";
echo $row1['message'];
echo "<br>";
echo $row1['date'];
echo"<hr>";
echo"</fieldset>";
}
它以错误的方式查看邮件 请任何人帮助我,谢谢:) 如果你不明白我在说什么 我的意思是我想知道如何查看消息
答案 0 :(得分:0)
首先从mysql_ *切换到mysqli_ *因为不推荐使用mysql_ *函数。
按升序排序查询:
$query1 = mysql_query("
SELECT *
FROM message
WHERE id_to = ".$idto."
AND id_from = ".$_SESSION['id']."
ORDER BY id ASC
");
$query2 = mysql_query("
SELECT *
FROM message
WHERE id_from = ".$idto."
AND id_to = ".$_SESSION['id']."
ORDER BY id ASC
");