user1114080
user1114080

Reputation: 65

Why Isn't My Data Being Shown?

I have the following tables in my database:

Minutes: minute_id, subject, next_subject, approval, meeting_id

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

I am using the following PHP code:

<?php

$result = mysql_query("SELECT * FROM Agendas INNER JOIN Minutes ON Minutes.meeting_id = Agendas.meeting_id WHERE Agendas.Approval = 'disapproved'")
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>";
?>

I am not getting the desired data to be shown as I am only been presented with the message 'You Have No New Messages' when in the agendas table, there is a row which has a field disapproved!

Any ideas?

Upvotes: 1

Views: 58

Answers (1)

Jason MacLean
Jason MacLean

Reputation: 513

You are doing an INNER JOIN... make sure there is also an associated row in the minutes table, or else there will be no data to return, even if there is an entry in Agendas.

Upvotes: 2

Related Questions