Here is the code for listing the records with check boxs
Code: Select all
<?php
<form name="delete" method="post" action="delmsg.php">
<input type="Submit" name="submit" value="Delete">
<?php $sql = "SELECT * FROM contact where type = 'msg'" ;
$rs=mysql_query($sql,$db);
while ($r = mysql_fetch_array($rs))
{
$msg=$r["msg"];
$name=$r["name"];
$email=$r["email"];
$comments=$r["comments"];
$date = strtotime($r["date"]);
$date = date("F jS y", $date); ?>
<?php echo $name ?>
<input type="Checkbox" name="msg[]" value="<? echo $msg; ?>">
</form>
<?php
}
?>Here is the code for deleteing the information from database
Code: Select all
<?php
for ($x=0; $x<sizeof($msg); $x++)
{
$db =mysql_connect("l","j", "");
mysql_select_db("",$db) or die ("cannot connect to database");
$query = "delete from contact where msg = '$msg[$x]'";
mysql_query($query);
}
header("Location:msg.php");
?>Many thanks