过滤数据库表中的记录以进行查看和更新

I'm currently trying to pull out records from database and display it on my php form for users to update it. In my database table, there's a column named stage. Under stage, there are foundation, intermediate and advance. Here's an example of it:

Valid XHTML http://img259.imageshack.us/img259/2461/databasei.png. Valid XHTML http://imageshack.us/photo/my-images/849/profileint.png/.

So when i press the foundation button in my php form(2nd picture), only records where theirs stage are foundation, will be shown on the list(together with their name, contact number, email and student ID) Is there any way that i can do that

Are you looking for something like this?

<?php
  $stage = $_GET['stage'];
  $sql = 'SELECT * FROM {$tablename} WHERE stage=:stage';

  $db = new PDO('mysql:host=localhost;dbname=yourdbname', $user, $pass);
  try {
    $statement = $db->prepare($sql);
    $statement->execute(array(':stage', db->quote($stage)));
    foreach($statement->fetchAll() as $row) {
      // Do things here.
    }
  } catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die();
  }
<?php
    include('connect-db2.php');

    // get results from database
    $result = mysql_query("SELECT * FROM players2 WHERE stage = 'foundation'") 
            or die(mysql_error());  

    echo "<table border='1' cellpadding='10'>";
    echo "<tr> <th>S/N</th> <th>Student_ID</th> <th>Name</th> <th>Contacts No.</th> <th>Email</th><th>Stage</th></tr>";

    while($row = mysql_fetch_array( $result )) {
        // echo out the contents of each row into a table
        echo "<tr>";
        echo '<td>' . $row['id'] . '</td>';
        echo '<td>' . $row['student_id'] . '</td>';
        echo '<td>' . $row['name'] . '</td>';
        echo '<td>' . $row['contact_no'] . '</td>';
        echo '<td>' . $row['email'] . '</td>';
        echo '<td>' . $row['stage'] . '</td>';
        echo '<td><a href="edit2.php?id=' . $row['id'] . '">Edit</a></td>';
        echo '<td><a href="delete2.php?id=' . $row['id'] . '">Delete</a></td>';
        echo "</tr>";
    } 
?>