Bonjour,

J'ai créé un formulaire pour mettre à jour plusieurs ligne de ma bdd en même temps.
J'arrive à afficher le statut actuel de la liste mais pour la mise à jour ... je bloque

Voici mon code actuel :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php 
 
//connexion à ma bdd
include 'bddconnect.php';
//uniquement si le formulaire est complété
//récupération des données du formulaire
 
	$ok = (isset($_POST['ok'])) ? $_POST['ok'] : '';
	$b = (isset($_POST['b'])) ? $_POST['b'] : '';
	$p = (isset($_POST['p'])) ? $_POST['p'] : '';
	$pk = (isset($_POST['pk'])) ? $_POST['pk'] : '';
	//Ajout dans la BDD
		if(isset($_POST['modifokbp'])){
		foreach ( $_POST['ok'] as $stamnummer=>$ok ) {
		$sql = "UPDATE sanctions 
		SET 
		sanction_ok = :ok, 
		sanction_b = :b, 
		sanction_p = :p
		WHERE sanction_pk = :pk
		";
		$stmt = $bdd->prepare($sql);
		$stmt->execute(array
		(
		':ok' => $ok, 
		':b' => $b, 
		':p' => $p,
		':pk' => $pk
		)
		);
				}
		echo '<img src="images/ok.gif" width="45" height="24"> La lsite a été mise à jour';
		$stmt->closeCursor();
		}
$sql="SELECT sanctions.sanction_type AS type_sanction, sanctions.sanction_pour AS pour_sanction, sanctions.sanction_nbr_h AS nbr_h_sanction, sanctions.sanction_date AS date_sanction, sanctions.sanction_ok AS ok_sanction, sanctions.sanction_motif AS motif_sanction, studenten.student_naam AS naam_student, studenten.student_voornaam AS voornaam_student, sanctions.sanction_pk AS pk_sanction, studenten.student_klas AS klas_student, studenten.student_stam AS student_stam, sanctions.sanction_b AS b_sanction, sanctions.sanction_e AS e_sanction, sanctions.sanction_p AS p_sanction
FROM studenten, sanctions
WHERE studenten.student_stam = sanctions.sanction_student AND sanctions.sanction_date = '2014-06-10'";
 
$results = $bdd->query($sql);
$i=1;
echo '<form method="POST" action=""><table width="100%" border="1" cellpadding="2">
  <tr>
    <th scope="col">Date</th>
    <th scope="col">Nom</th>
    <th scope="col">Billet</th>
    <th scope="col">Pages</th>
    <th scope="col">Ok</th>
  </tr>';
while( $row=$results->fetch() ){
$checkedokO = ($row['ok_sanction'] === '1') ? 'checked' : '';
$checkedokN = ($row['ok_sanction'] === '0') ? 'checked' : '';
$checkedbO = ($row['b_sanction'] === '1') ? 'checked' : '';
$checkedbN = ($row['b_sanction'] === '0') ? 'checked' : '';
$checkedpO = ($row['p_sanction'] === '1') ? 'checked' : '';
$checkedpN = ($row['p_sanction'] === '0') ? 'checked' : '';
		echo '<tr>
    <td>'.$row['date_sanction'].'</td>
    <td>'.$row['naam_student'].' '.$row['voornaam_student'].' '.$row['klas_student'].'</td>
    <td><input type="radio" name="b['.$row['student_stam'].']" value="1" '.$checkedbO.'>Oui<input type="radio" name="b['.$row['student_stam'].']" value="0" '.$checkedbN.'>Non
  </td>
    <td><input type="radio" name="p['.$row['student_stam'].']" value="1" '.$checkedpO.'>Oui<input type="radio" name="p['.$row['student_stam'].']" value="0" '.$checkedpN.'>Non
  </td>
    <td><input type="radio" name="ok['.$row['student_stam'].']" value="1" '.$checkedokO.'>Oui<input type="radio" name="ok['.$row['student_stam'].']" value="0" '.$checkedokN.'>Non
  </td>
  </tr>

<input type="hidden" name="pk" value="'.$row['pk_sanction'].'">
';
		}
$results->closeCursor();
?>
</table>
<input type="submit" value="Mettre à jour la liste" name="modifokbp">
</form>
La partie update ne fonctionne pas.

Dans quelle direction dois-je chercher ? Je suis perdu

Merci d'avance pour votre aide

;-)
Sub