My code join 4 table using INNER JOIN. I can't customize loop while using inner join. How to control while clause so unwanted loop wouldn't happen.
My code output (student and school name is looping in every subject field)
I want to display like this where student and school loops at once.
MY PHP Code
<table id="customers">
<?php
$query=$con->prepare("SELECT subjectcomb.subjectid, subjectcomb.schoolid, student.student, school.school, subject.name
FROM ((( subjectcomb
INNER JOIN school ON subjectcomb.schoolid=school.id)
INNER JOIN student ON subjectcomb.schoolid=student.schoolID)
INNER JOIN subject ON subjectcomb.subjectid=subject.id)");
$query->execute();
while ($row = $query->fetch(PDO::FETCH_ASSOC)){?>
<tr>
<td>
<?php echo $row['school']."->".$row['student']?>
</td>
</tr>
<tr>
<td>
<?php echo $row['name']?>
<input type="text" name="mark"></input>
</td>
</tr>
<?php } ?>
</table>


ifjudgement before the first<tr>and judge whether you have already output thisschoool->studentcould solve this issue. But I guess you want to solve it just with SQL command?group by student.student, school.schoolin your query?