First things first.
It's bad idea to use mysql
as it is really old and it's deprecated.
Second, where do you assign your variables ($delete
, $count
)
you have to check if the delete
key of your POST
is set:
if (isset($_POST['delete'])) { // Then the form has been submitted
after this, assign your $count
variable
$checkbox = $_POST['checkbox'];
$count = count($checkbox);
And everything must work fine.
Final result
if (isset($_POST['delete'])) {
$checkbox = $_POST['checkbox'];
$count = count($checkbox);
for($i = 0; $i < $count; $i++) {
$id = (int) $checkbox[$i]; // Parse your value to integer
if ($id > 0) { // and check if it's bigger then 0
mysql_query("DELETE FROM table WHERE member_id = $id");
}
}
}
Check out the mysqli and the PDO drivers for interacting with the database.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…