hey guys so I’m trying to delete a row from table which is connected to database using checkbox(and it wouldnt matter if its just one row or multiple rows) but it is not working, as in nothing happens. it doesn’t delete, no errors or warnings appear just a refresh.
page :
[CODE]
<form class=”buttons” method=”post” action=”event.php”>
<div class=”button-wrap”>
<input type=”button” id=”add_event” name=”add_event” value=”Add Event”/>
<input type=”submit” id=”del_event” name=”del_event” value=”Delete Event”/>
</div>
</form>
<form method=”post” action=”contact_data.php”>
<table class=”contact-list-table”>
<thead>
<tr>
<th >Salutation</th>
<th>Name</th>
<th>House Address</th>
<th>Email Address</th>
<th>Telephone No.</th>
<th>Office No.</th>
</tr>
</thead>
<tbody>
<?php
require “connection.php”;
$check = mysql_query(“SELECT * FROM contact”) or die(mysql_error());
$count=mysql_num_rows($check);
if($count > 0)
{
while($rows = mysql_fetch_array($check))
{
$salutation = $rows[‘salutation’];
$firstname = $rows[‘fname’];
$lastname = $rows[‘lname’];
echo
“<tr>
<td ><input type=’checkbox’ name=’check[]’ class=’check’ value=’$id’>$salutation</td>
<td>$firstname $lastname</td>
</tr>”;
}
}
else
{
echo
“<tr>
<td colspan=’6′>Contact Database is empty.</td>
</tr>”;
}
?>
</tbody>
<?php
if (isset($_POST[‘del_contact’]) && isset($_POST[‘check’]))
{
foreach($_POST[‘check’] as $del_id)
{
$del_id = (int)$del_id;
$sql = “DELETE FROM contact WHERE contact_id = $del_id”;
mysql_query($sql);
}
}
?>
</table>
</form>
[CODE]if (isset($_POST[‘del_contact’])
‘del_event’ is a name of a delete button which is disabled unless a checkbox is checked.
any help is mush appreciated.