user1114080
user1114080

Reputation: 65

Where Clause Does Not Seem To Be Working

I have a inner join statment which is working 90% as it is displaying what I need it to display but unfortunately it is not displaying to the right user logged in. It is being displayed to whoever logs into my system. Here is the code:

    <?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>";
?>

my database tables look like this:

Meetings: meeting_id, title, chairperson, secretary, tof, occurances, action

Agendas: agenda_id, subject, duration, meeting_id, approval, reason.

thanks soo much for any help :)

Upvotes: 0

Views: 49

Answers (1)

davogotland
davogotland

Reputation: 2777

i think you're doing something wrong in the join clause. how about this:

$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());

Upvotes: 1

Related Questions