我有一个内部联接语句,它正在显示我需要它显示的内容90%,但不幸的是它没有显示给登录的正确用户。它显示给登录我系统的任何人。这是代码:
<?php
$result = mysql_query("SELECT * FROM Agendas INNER JOIN Meetings ON Meetings.secretary WHERE Agendas.approval = 'disapproved' AND secretary = '". $_SESSION['username']."'")
or die(mysql_error()); ;
if (mysql_num_rows($result) == 0) {
echo 'You Have No New Messages';
} else {
while($info = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><br/>" .'Title: '. $info['title']." </td>";
echo "<td><br/>" .'Approved: '. $info['approval']. "</td>";
echo "<td><br/>" .'Reason: '. $info['reason']."</td>";
echo "<hr>";
}
}
echo "</tr>";
echo "</table>";
?>
我的数据库表格如下所示:
会议:meeting_id,职称,主席,秘书,职权,出现,行动
议程:议程_id,主题,持续时间,meeting_id,批准,原因。
非常感谢任何帮助:)
答案 0 :(得分:1)
我认为你在join子句中做错了什么。怎么样:
$result = mysql_query("SELECT * FROM Agendas INNER JOIN Meetings ON Agendas.meeting_id = Meetings.meeting_id WHERE Agendas.approval = 'disapproved' AND secretary = '". $_SESSION['username']."'")
or die(mysql_error());