I'm having a problem with deleting data using checkbox. I actually, retrieve all the records that I want to show/display. But the Delete button doesn't work.
$sql="SELECT * FROM admin";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
<?php
while($rows=mysql_fetch_array($result)){
echo "<tr>";
echo "<td>" . "<input type='checkbox' name='check[]' value='".$rows['id']."'/>" . "</td>";
echo "<td>" . $rows['username'] . "</td>";
echo "<td>" . $rows['email'] . "</td>";
echo "</tr>";
?>
<input name="delete" type="submit" id="delete" value="Delete">
Here's the IF STATEMENT to check if the delete button was active.
if($delete){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM admin WHERE id='$del_id'";
$result = mysql_query($sql);
}
// if successful redirect to delete_multiple.php
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_admin.php\">";
}
}
Any help is appreciated. Thank you!