Try this, homie :
<head></head>
<body>
<?php
include "db.php";
// see that the variable is up top (?delStudent=student's name), if they are simply
// coming into the page for the first time, there will be no variable there, so it
// will not delete anyone
if($delStudent) {
// your delete query
$delSQL="delete from students where username='$delStudent'";
// execute it, not sure if this is the way it's done with MySQL, I use Oracle 8i
mysql_query("$delSQL");
}
?>
<table border="1">
<tr>
<td>Username</td>
<td>First Name</td>
<td>Surname</td>
<td>Email</td>
<td>Course</td>
</tr>
<?php
$sql = "select username, student_firstname, student_surname, student_email, course_id from students order by username";
if ($result = mysql_query("$sql")) {
while ($row = mysql_fetch_array ($result)) {
print("<tr>\n");
print("<td>$row[username]</td>\n");
print("<td>$row[student_firstname]</td>\n");
print("<td>$row[student_surname]</td>\n");
print("<td>$row[student_email]</td>\n");
print("<td>$row[course_id]</td>\n");
// when it comes back to viewstudents.php, it will invoke the procedure above, deleting $row[username]'s row
print("<td><a href=viewstudents.php?delStudent=$row[username]>Delete</a></td>\n");
print("</tr>\n");
}
}
?>
</table>
<?php include "endpage.php"; ?>
</body>