我有两张桌子mysql
。以下是我的脚本。
<?php
$conn=mysql_connect("localhost",'root','');
mysql_select_db('test');
$sql = "SELECT data_student.name,ozekimessagein.msg
FROM ozekimessagein,data_student
WHERE ozekimessagein.sender=data_student.sender
ORDER BY ozekimessagein.msg";
$res=mysql_query($sql);
$cn=mysql_num_rows($res);
for($x=0;$x<$cn;$x++)
{
list($name,$msg)=mysql_fetch_row($res);
echo "<li>$name,$msg";
}
mysql_close($conn);
?>
只要表中的发件人与表中的发件人匹配,这应该显示表中的名称data_student
和消息。但它不起作用。ozekimessagein
data_student
ozekimessagein