hi everyone..hope every1 is going great..well i'm a beginner in mysql and php and i cant fix the query as i desire..iam joining 3 tables here and displaying thre data..
1st i have displayed course names from the courses table
2nd i have displayed the subject names from wich the courses belong.
3rd i want to display the status (if any) of each course from request records table,
when the student wants an approval he just applies the course and the status (applied) is saved in request records with 2 foreign keys (coursesid & studentid) here when i display the 3rd table's status it shows only the rows of those courses for whom i've applied..but not the list of all courses.. please help.. i want it to display list of all courses + status if any...
this is offered-courses.php
<?php
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($dbname, $con);
$result = mysql_query("SELECT courses.id AS cid, courses.title, courses.subjectsid, subjects.id AS sid, subjects.subjectname, requestrecord.status FROM courses, subjects, requestrecord WHERE (courses.subjectsid=subjects.id AND courses.id=requestrecord.coursesid)");
echo "<table border='1' style='width:500px;'> <br />
<tr>
<th>Course Name</th>
<th>Subject </th>
<th>Action</th>
<th>Status</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['title'] . "</td>";
echo "<td>" . $row['subjectname'] . "</td>";
echo "<td><a href='request-for-approval.php?id=".$row['cid']."& sid=".$row['sid']."'>Apply!</a></td>";
echo "<td>" . $row['status'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>