I'm attempting to delete a row from a table with data that is generated from a MySQL table. I took a look at both of these questions: 1. How to delete rows of database results using checkbox 2.Deleting multiple rows using checkboxes, PHP and MySQL.
I need help for code delete using checkboxes..
<?php
$sql = mysqli_query($conn, "SELECT * FROM leads ORDER BY lid ASC");
if(mysqli_num_rows($sql) == 0){
echo '<tr><td colspan="8">No Data Entry</td></tr>';
}else{
while($row = mysqli_fetch_assoc($sql)){
echo '<tr>
<td> <input name"checkbox[]" value"'.$row['lid'].'" type="checkbox"></td>
<td>'.$row['name'].'</td>
<td>'.$row['sex'].'</td>
<td>'.$row['phone'].'</td>
<td>'.$row['company'].'</td>
<td>'.$row['vehicle'].'</td>
</tr>';
}
}?>
Cancel
<?php
$del_lid = $_POST['checkbox'];
if (isset($_POST['submit'])) {
foreach($del_lid as $value){
$sql = "DELETE FROM leads WHERE lid='".$value."'";
$result = mysqli_query($conn, $sql);
}
}
?>
value"'.$row['lid'].'"