I have a table showing information from a mysql table and in the last column I have a checkbox like this :
<form method="POST" action="php/delete.php">
<thead>
<tr
<th>Nom</th>
<th>Espéce</th>
<th>Cri</th>
<th>Propiétaire</th>
<th>Age (années)</th>
<th><input type="submit" name="supprimer" value="Supprimer" /></th>
</tr>
</thead>
<tbody>
<?php
$connexion = mysql_connect($hote, $login, $mdp);
mysql_select_db($bd, $connexion);
$req = "Select * from animaux;";
$resultat = mysql_query($req, $connexion);
while (list($id, $nom, $esp, $cri, $prop, $age) = mysql_fetch_row($resultat)) {
?>
<tr>
<td><?= $nom ?> </td>
<td><?= $esp ?></td>
<td><?= $cri ?></td>
<td><?= $prop ?></td>
<td><?= $age ?></td>
<td> <input type="checkbox" name="choix[]" value=<?= $id ?>></td>
</tr>
<?php } ?>
</form>
I am using the following script to delete the rows :
include("../BD/bd_params.inc.php");
$connexion = mysql_connect($hote,$login,$mdp);
mysql_select_db($bd, $connexion);
$del = $_POST['choix'];
foreach ($del as $val) {
$req = "delete from `animaux` where id = '$val'";
$resultat = mysql_query($req,$connexion);
if (!resultat) {
die('Requête invalide : ' . mysql_error());
break;
}
}
However when i submit the form nothing happens, nothing is shown and nothing is deleted. Does anyone what could be causing my script not working ?
(oh, and sorry for my english ...)
error_reporting(E_ALL);andini_set('display_errors', 'on');var_dump($_POST);when i check several boxes, it shows :array(2) { ["supprimer"]=> string(9) "Supprimer" ["choix"]=> array(1) { [0]=> string(1) "6" } }. So apparently, the array 'choir' doesn't work properly...print_r($_POST), what do you see?