I am trying to create a page where students can view the homework set by teacher for their classes. With the query I have now, it is not giving me any errors, but it's not returning the right classes. Instead it appears to show the latest that have been added. Here is my SQL statement.
What I need is a statement which selects from each class that the student that is logged in is associated with.
$id= $_SESSION['id'];
mysqli_query($conn, "SELECT * FROM class INNER JOIN student_class ON class.class_id=student_class.class_ID INNER JOIN student ON student.ID= student_class.class_ID WHERE tbluser_ID='$id' ");
Here is how I want the information to be displayed
<table width='80%' border=0>
<tr bgcolor='#CCCCCC'>
<td>ID</td>
<td>Class Name</td>
<td>Manage </td>
</tr>
<?php
//while($res = mysql_fetch_array($result))
while($res = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>".$res['class_id']."</td>";
echo "<td>".$res['classname']."</td>";
And here is my database