-- Here is my view code --
<form action="removeteach.php" method="post">
<?
$link = mysql_connect("localhost", "jjamies_ciggie", "cas483") or die ("Could not connect to database");
mysql_select_db("jjamies_users", $link) or die ('Can\'t use db : ' . mysql_error());
$result = mysql_query("SELECT teachid FROM teacherid") or die ('Can\'t use db : ' . mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records in the database.<p>";
print "<table border=1 width=75%>\n";
print "<tr>\n";
print "<td colspan=2>\n";
print "<b>Techer ID</b>\n";
print "</td>\n";
print "</tr>\n";
while ($get_info = mysql_fetch_row($result)) {
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><input type=\"checkbox\" name=\"remove[]\" value=\"" . $get_info['teachid'] . "\" /></td>\n";
print "\t<td>$field</td>\n";
print "</tr>\n";
}
print "</table>\n";
?>
<input type="submit" name="submit" value="remove">
</form>
-- here is my remove code (removeteach.php) --
<?php
if (isset($HTTP_POST_VARS['remove'])) {
foreach ($HTTP_POST_VARS['remove'] as $teachid)
mysql_query("DELETE FROM teacherid WHERE teachid = '" . $teachid . "'") or die ('Can\'t delete : ' .
mysql_error());
}
else
echo "No items selected";
?>
If you'd like to see what it does now:
http://www.jjamieson.com/cas483/php/viewteach.php