rendered paste body// Delete quiz and related details
if (isset($_POST['delquiz']))
{
echo "test1";
if ( count($delquiz) !=0 )
{
echo "test2";
echo "you have succesfully deleted:<br>";
foreach ( $delquiz as $quizid )
{
$result2 = mysql_query("SELECT * FROM `questiontable` WHERE `quizid` = '$quizid'");
if (!mysql_num_rows($result2) == 0)
{
while($row = mysql_fetch_array($result2))
{
$questionid = $row['questionid'];
echo "test3";
$result3 = mysql_query("DELETE FROM answertable WHERE questionid = '$questionid'");
}
}
$result = mysql_query("DELETE FROM questiontable WHERE quizid='$quizid'")
or die(mysql_error());
}
$result = mysql_query("DELETE FROM quiztable WHERE course='$course'")
or die(mysql_error());
}
else echo "You have not selected any quizzes to delete.";
}
// Delete quizzes
$res = mysql_query("SELECT * FROM `quiztable` WHERE `course` = '$course'");
if (!mysql_num_rows($res) == 0)
{
echo "<br>Here are the quizes supplied for this course:<br>";
echo "<table border='1'>
<tr>
<th>Quiz</th>
<th>Delete?</th>
</tr>";
echo "<form name='delquiz' method='post' action='teacher.php?course=" . $course . "'>";
$i=1;
while($row = mysql_fetch_array($res))
{
echo "<tr>";
echo "<td>" . $row['title'] . "</td>";
echo "<td> <input type='checkbox' value='" . $row['quizid'] . "' name='delquiz[$i]'> </td>";
echo "</tr>";
$i++;
}
echo "</table>";
echo "<input type='submit' name='submit' value='Delete'>";
echo "</form><br><br>";
}
else echo "<br>There are currently no quizes supplied for this course.<br>";