i'm trying to delete from the database multiple rows using checkboxes.
I have an html table inside a foreach loop to seek the table values.
And i want to put a delete button inside this table to delete all the values from a certain row.
But i dont know how to do that, i'm using this code:
if (isset($_POST['delete']) && (!empty($_POST['checkbox']))){
$del_id = $_POST['checkbox'];
foreach($del_id as $value){
$sql = "DELETE FROM my_table WHERE id='".$value."'";
$result = mysql_query($sql);
}
}
And i have this code inside the foreach loop
<td><input style='width: 50px;' class='delete' value='delete' name='checkbox' type='checkbox'/></td>
<input type='hidden' name='id' value=".$key['job_id']." />