Hello,
I'm trying to display a table in PHP that uses multiple MySQL tables with some repeated field names.
Master table field names: Name, Student Major, Course Major, Course #, Credits, Course Name
This is what I have so far...but the variables in the loop are not working and I'm not sure how to reference them individually.
<?php
$result = mysql_query("SELECT s.descr, m1.descr, m2.descr, c.number, c.credits, c.descr
FROM student AS s, major AS m1, class__student_course AS cl, course AS c, major AS m2
WHERE s.major_id = m1.id
AND s.id = cl.student_id
AND cl.course_id = c.id
AND c.major_id = m2.id
ORDER BY s.last_name, s.first_name, m1.descr, m2.descr, c.number;");
echo "<table border='1'>
<tr><h2>MasterMaster Table</h2>
<th>Student Name<z/th>
<th>Student Major</th>
<th>Course Major (department)</th>
<th>Course #</th>
<th>Credits</th>
<th>Course Name</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['s.descr'] . "</td>"; //Name
echo "<td>" . $row['m1.descr'] . "</td>"; //Student Major
echo "<td>" . $row['m2.descr'] . "</td>"; //Course Major
echo "<td>" . $row['c.number'] . "</td>"; //Course #
echo "<td>" . $row['c.credits'] . "</td>"; //Credits
echo "<td>" . $row['c.descr'] . "</td>"; //Course Name
echo "</tr>";
}
echo "</table>";
?>
Thank you for your help!