Duplicate Row titles in Sql. Print in PHP

I’m having trouble with my php as you can see, i have 2 rows in a data base with duplicate names (Teacher 1st/last name and student 1st/last name).
when i use this code below it shows this on the webpage

  SubjectID: 1
  Subject name: English
  Teacher First Name: TeachFirst1
  Teacher Last Name: TeachLast1
  Class List
  Student First Name: TeachFirst1
  Student Last Name: TeachLast1

How can i specify that i want the last 2 line to print the student’s first/last name? Not the teachers. i know why its printing the teachers. i just want it to be specified

$sql2 = 'SELECT `students`.`FirstName`, `students`.`LastName`, `subjects`.`SubjectName`, `subjects`.`SubjectNo`, `teachers`.`FirstName`, `teachers`.`LastName`
                    FROM `students`
                    INNER JOIN `timetable` ON `students`.`StudentID`=`timetable`.`StudentID`
                    INNER JOIN `subjects` ON `timetable`.`Subject`=`subjects`.`SubjectNo`
                    INNER JOIN `teachers` ON `subjects`.`TeacherID`=`teachers`.`TeacherID`
                    WHERE `timetable`.`subject`="1"';

            $results2 = $conn->query($sql2);
            if($results2->num_rows > 0){
                while ($row=$results2->fetch_assoc()) {
                    echo "<br/>".
                    "<b>"."SubjectID: "."</b>".$row["SubjectNo"]. "<br/>".
                    "<b>"."Subject name: "."</b>".$row["SubjectName"]. "<br/>".
                    "<b>"."Teacher First Name: "."</b>".$row["FirstName"]. "<br/>".
                    "<b>"."Teacher Last Name: "."</b>".$row["LastName"]. "<br/>".
                    "<b>"."Class List"."</b>"."<br/>".
                    "<b>".'Student First Name: '."</b>".$row["FirstName"]. "<br/>".
                    "<b>".'Student Last Name: '."</b>".$row["LastName"]. "<br/>"

In your query use the alias to change the name of the teacher or student

`teachers`.`FirstName` AS t_FirstName, `teachers`.`LastName` AS t_LastName

In the while alter

"<b>".'Student First Name: '."</b>".$row["FirstName"]. "<br/>" 

to “<b>”.’Student First Name: ‘.”</b>”.$row[“t_FirstName”]. “<br/>”, for example

Change your select to below to rename the columns.

SELECT `students`.`FirstName` as studentFirstName, 
       `students`.`LastName` as studentLastName, 
       `teachers`.`FirstName` as teacherFirstName, 
       `teachers`.`LastName` as teacherLastName 

And in your php code use the assigned names:

"<b>"."Teacher First Name: "."</b>".$row["teacherFirstName"]. "<br/>".
"<b>"."Teacher Last Name: "."</b>".$row["teacherLastName"]. "<br/>".
"<b>".'Student First Name: '."</b>".$row["studentFirstName"]. "<br/>".
"<b>".'Student Last Name: '."</b>".$row["studentLastName"]. "<br/>"