我在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
表發送方的消息。但它不起作用。
關閉主題:選中此[爲什麼不應該使用mysql_ *函數在PHP?](http://stackoverflow.com/questions/12859942/why-shouldnt -i-use-mysql-function-in-php) – nu6A