try this code
<html>
<body style="background-color:#E0FFFF;">
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_course", $con);
$result = mysql_query("SELECT * FROM Courses ORDER BY Year, Sem, CourseCode");
echo "<table border='1' cellpadding='2' cellspacing='0'>
<tr>
<th>CourseCode</th>
<th>CourseName</th>
<th>Year</th>
<th>Sem</th>
<th>Grade</th>
<th>Option</th>
</tr>";
?>
<?php
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['CourseCode'] . "</td>";
echo "<td>" . $row['CourseName'] . "</td>";
echo "<td>" . $row['Year'] . "</td>";
echo "<td>" . $row['Sem'] . "</td>";
echo "<td>" . $row['Grade'] . "</td>";
?>
<td><a href="submitDelete.php?code=<?php echo $row['CourseCode'];?>">Cancel</a></td>
<?php
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
</body>
</html>
and submitDelete.php is
<html>
<body style="background-color:#E0FFFF;">
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_course", $con);
mysql_query("DELETE FROM Courses WHERE CourseCode='".$_GET['code']."'");
mysql_close($con);
header('Location: http://localhost/Database/viewcourses2.php');
?>
</body>
</html>