单行重复而不是显示

I'm pretty new at PHP/MySQL, so please be patient with me.

I am trying to get a list of members in a table to show up on a page. Right now it's showing the first member about 10 times and not displaying anyone else's name. I DID have it working, but I don't know what happened. I just want it to display everyone's name once. Here is my code:

<?php $select = mysql_query("SELECT * FROM `member_staff` WHERE `username`='$_SESSION[USR_LOGIN]' AND `status`='Active'");
$row = mysql_fetch_array($select);
$rows = mysql_num_rows($select);
$teaching = $row[teaching];
if ($rows==0){echo "Sorry, you don't appear to be a professor.";}
else { ?>

<?php }
    $select2 = mysql_query("SELECT * FROM `classes_enrolled` WHERE `course`='" . $teaching . "' ORDER BY `student_name`") or die(mysql_error());
    $count = mysql_num_rows($select2);
    $row2 = mysql_fetch_array($select2);
    $student=$row2[student_name];
    if($count==NULL) {
        echo "<table width=\"80%\">
";
        echo "<tr><td><center>Nobody has registered for your class yet!</center></td></tr>
";
        echo "</table>
";
        echo "<br /><br />

";
    }

    else {
        echo "<center><font size=\"3\"><b>YEAR 1, TERM 2</b></font></center>";
        echo "<table width=\"80%\" class=\"table-stripes\">
";
        echo "<tr><td width=\"50%\"><b>STUDENT</b></td></tr>
";
    $select3 = mysql_query("SELECT * FROM `members` WHERE `username`='" . $student . "'") or die(mysql_error());
    $row3 = mysql_fetch_array($select3);
        while($row2 = mysql_fetch_array($select2)) {
        $house=$row3[house];
        echo "<tr><td><strong class=\"$house\">$student</strong></td></tr>";
        }
    echo "</table>"; }
?>

I miss look on your code, since it is mess, but disregard the mysqli and mysql thing, you want to show how many student in the teacher's classes.

<?php $select = mysql_query("SELECT * FROM `member_staff` WHERE `username`='$_SESSION[USR_LOGIN]' AND `status`='Active'");
$row = mysql_fetch_array($select);
$rows = mysql_num_rows($select);
$teaching = $row[teaching];  <--- This only get first row of the course, if you want multiple course under same username, you need to loop it.
if ($rows==0){echo "Sorry, you don't appear to be a professor.";}
else { ?>

<?php }
    $select2 = mysql_query("SELECT * FROM `classes_enrolled` WHERE `course`='" . $teaching . "' ORDER BY `student_name`") or die(mysql_error());
    $count = mysql_num_rows($select2);
    $row2 = mysql_fetch_array($select2);
    $student=$row2[student_name];  <----- This only get the first row of the student name, if you want multiple student under a course, you need to loop it.
    if($count==NULL) {
        echo "<table width=\"80%\">
";
        echo "<tr><td><center>Nobody has registered for your class yet!</center></td></tr>
";
        echo "</table>
";
        echo "<br /><br />

";
    }

    else {
        echo "<center><font size=\"3\"><b>YEAR 1, TERM 2</b></font></center>";
        echo "<table width=\"80%\" class=\"table-stripes\">
";
        echo "<tr><td width=\"50%\"><b>STUDENT</b></td></tr>
";
    $select3 = mysql_query("SELECT * FROM `members` WHERE `username`='" . $student . "'") or die(mysql_error());
    $row3 = mysql_fetch_array($select3);
        while($row2 = mysql_fetch_array($select2)) {
        $house=$row3[house];  <----This only show the first row of $house under same student, so you need to loop it too.
        echo "<tr><td><strong class=\"$house\">$student</strong></td></tr>";
        }
    echo "</table>"; }
?>

So what you really want to do is

<?php 
$select = mysql_query("SELECT * FROM `member_staff` WHERE `username`='$_SESSION[USR_LOGIN]' AND `status`='Active'");
$rows = mysql_num_rows($select);
if ($rows==0){echo "Sorry, you don't appear to be a professor.";}
else { ?>

<?php }
    while( $row = mysqli_fetch_array( $select ) ) {
      $teaching = $row[teaching];
      $select2 = mysql_query("SELECT * FROM `classes_enrolled` WHERE `course`='" . $teaching . "' ORDER BY `student_name`") or die(mysql_error());
      $count = mysql_num_rows($select2);
      if($count==NULL) {
        echo "<table width=\"80%\">
";
        echo "<tr><td><center>Nobody has registered for your class yet!</center></td></tr>
";
        echo "</table>
";
        echo "<br /><br />

";
      } else {

        while( $row2 = mysql_fetch_array($select2) ) {
           $student=$row2[student_name]; 
           echo "<center><font size=\"3\"><b>YEAR 1, TERM 2</b></font></center>";
           echo "<table width=\"80%\" class=\"table-stripes\">
";
           echo "<tr><td width=\"50%\"><b>STUDENT</b></td></tr>
";
           $select3 = mysql_query("SELECT * FROM `members` WHERE `username`='" . $student . "'") or die(mysql_error());
           while($row3 = mysql_fetch_array($select3)) {
              $house=$row3[house];
              echo "<tr><td><strong class=\"$house\">$student</strong></td></tr>";
           }
           echo "</table>"; 
        }
    }  // END ELSE
 }
} // END ELSE
?>