Hi all,
Im having a little trouble getting my form to delete multiple records.
Currently with each record displayed there is a checkbox that when the user checks and clicks delete, is suppose to delete those records, but it dosn't. There are no error messages at all but the record is simply not deleted??
If you could have little peak and see whats up that would be greatπ
Thanks π
<?php require_once('Connections/woodside.php'); ?>
mysql_select_db($database_woodside, $woodside);
$query_Recordset1 = sprintf("SELECT * FROM animalfears WHERE AnimalID = %s", $colname_Recordset1);
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $woodside) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if($_POST['perform']) {
foreach($_POST as $id) { // This will loop through the checked checkboxes
mysql_select_db($database_woodside, $woodside);
$query_test="DELETE FROM animalfears WHERE AnimalFearID='" . $row_Recordset1['AnimalFearID'] ."'"; // Change yourtable and id.
$test = mysql_query($query_test, $woodside) or die(mysql_error());
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form name="action" id="action" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<table width="465" border="1">
<tr>
<?php do { ?>
<td><?php echo $row_Recordset1['FearID']; ?></td>
<td><label>
<input type="checkbox" name="<?php echo $row_Recordset1['AnimalFearID']; ?>" id="<?php echo $row_Recordset1['AnimalFearID']; ?>" value="<?php echo $row_Recordset1['AnimalFearID']; ?>" />
</label></td>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?></tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
<p>
<label>
<input type="submit" name="perform" id="perform" value="Delete Selected" />
</label>
</p>
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
[ Mod Edit - bpat1434 ] Changed [code] tags to [php] tags.