0
In the code that I am creating there is a view of all the users of the site in an html table, until then everything right, however when selecting multiple checkbox to delete several users of the site simply nothing happens only the page updates but the data is still there, code I created:
<?php
include("connection.php");
session_start();
?>
<table width="100%">
<thead>
<tr>
<th>
Sel.
</th>
<th>
ID
</th>
<th>
Permissão
</th>
<th>
Status
</th>
</tr>
</thead>
<tbody>
<?php
$select = $mysqli->query("SELECT * FROM usuarios ORDER BY ID ASC");
$row = $select->num_rows;
if ( $row > 0 ) {
while ($get = $select->fetch_array()) {
$data_mysql = $get["LogouUltimoSite"];
$timestamp = strtotime($data_mysql);
$status = $get["Status"];
$permissao = $get["Permissao"];
?>
<tr>
<td>
<input type="checkbox" name="chk[]" value="<?= $get["ID"] ?>"/>
</td>
<td>
<?= $get["ID"] ?>
</td>
<td>
<?php
if ( $permissao == 0 ) {
echo("Membro");
} else {
echo("Admin.");
}
?>
</td>
<td>
<?php
if ( $status == 0 ) {
echo("Normal");
} else {
echo("Banido");
}
?>
</td>
</tr>
<?php
}
} else {
?>
<h4> Não existe nenhum usuário ! </h4>
<?php
}
?>
</tbody>
</table>
<form method="POST">
<input class="button" type="submit" name="button" value="Excluir"/>
</form>
<?php
$chk = $_POST["chk"];
if ( isset($_POST["button"]) ) {
foreach ($chk as $item) {
$mysqli->query("DELETE FROM usuarios WHERE ID='" . $item . "'");
$mysqli->close();
}
}
?>
Thank you in advance if you can help me.
It may be that in the code there is some part missing, in case this happens was the fact of having cut it so that it was not too extensive !