Bonjour à tous, j'ai un tableau que je récupère via une requete php mysql (en fait je récupère plusieurs enregistrements d'une table) et le tout s'affiche ligne par ligne dans des champs html de type texte. voici la requête:
ensuite je fais un form method post sur une autre page et la j'essaye d'insérer les données récupérées et modifiées via les input, j'ai donc fais ceci:
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 <?php $sql = "SELECT * FROM scenarii where code_s='".mysql_real_escape_string($_POST['code_s'])."'"; $qry = mysql_query($sql) or die(__LINE__.mysql_error().$sql); $get_date = function($data_jours) { $today = new DateTime(); $today->setTime(0, 0); $jours = (isset($_POST['jours']) && ctype_digit($_POST['jours'])) ? $_POST['jours'] : 0; if (isset($_POST['submit']) && ($_POST['submit'] === 'moins')) { $jours = -$jours; } $nb = $data_jours + $jours; $func = ($nb < 0) ? 'sub' : 'add'; $interval = new DateInterval("P{$nb}D"); return $today->$func($interval)->format('d-m-Y'); }; $i = -1; // index des enregistrements ?> <table cellpadding="5" cellspacing="5"> <tr> <td><strong>CODE SCENARIO</strong></td> <td><strong>LIBELLE</strong></td> <td><strong>ACTION</strong></td> <td><strong>DESCRIPTION</strong></td> <td><strong>DATE</strong></td> </tr> <form action="<?php echo (isset($_POST['go'])) ? 'go.php' : '#'; ?>" method="post"> <input type="hidden" name="liasse" value="<?php echo $_POST['liasse']; ?>"/> <?php while($row = mysql_fetch_assoc($qry)): ?> <tr> <td><input name="data[<?php echo ++$i; ?>][code_s]" type="text" value="<?php echo $row['code_s'];?>" size="10"></td> <td><input name="data[<?php echo $i; ?>][titre]" type="text" value="<?php echo $row['titre']; ?>" size="45"></td> <td><input name="data[<?php echo $i; ?>][action]" type="text" value="<?php echo $row['action']; ?>" size="15"></td> <td><input name="data[<?php echo $i; ?>][libelle]" type="text" value="<?php echo $row['libelle']; ?>" size="55"></td> <td><input type="text" name="data[<?php echo $i; ?>][date]" value="<?php echo $get_date($row['jour']); ?>" size="12"></td> </tr> <?php endwhile; ?> <p> <strong>Décalage des date </strong> <table width="150" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" bgcolor="#FFFF99"><input type="hidden" name="code_s" value="<?php echo $_POST['code_s']; ?>"> <input type="image" src="images/minus_remove_green.png" width="22" height="22" name="submit" value="moins" /> <input name="jours" type="text" value="" size="5" /> <input type="image" src="images/plus_add_green.png" width="22" height="22" name="submit" value="plus" /> </td> </tr> </table>
le soucis c'est que j'ai plein de message d'erreur, a priori je fais quelque chose de mauvais mais quoi? je ne sais pas.
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 <?php //var_dump($_POST['data']) ; $value = $_POST['data'] ; foreach($value as $cle => $valeur) { $sql = 'INSERT INTO agenda SET code_s = "'.mysql_real_escape_string($_POST['data[][code_s]']).'", date = "'.mysql_real_escape_string($_POST['data[][date]']).'", libelle = "'.mysql_real_escape_string($_POST['data[][libelle]']).'", action = "'.mysql_real_escape_string($_POST['data[][libelle]']).'"'; } ?>
voila ce que j('ai à titre indicatif:
) Notice: Undefined index: data[][code_s] in C:\wamp\www\NEOGETCASH\GESTIONNAIRE\go.php on line 190
Call Stack
# Time Memory Function Location
1 0.0006 727504 {main}( ) ..\go.php:0
( ! ) Notice: Undefined index: data[][date] in C:\wamp\www\NEOGETCASH\GESTIONNAIRE\go.php on line 191
Call Stack
# Time Memory Function Location
1 0.0006 727504 {main}( ) ..\go.php:0
( ! ) Notice: Undefined index: data[][libelle] in C:\wamp\www\NEOGETCASH\GESTIONNAIRE\go.php on line 192
Call Stack
# Time Memory Function Location
1 0.0006 727504 {main}( ) ..\go.php:0
( ! ) Notice: Undefined index: data[][libelle] in C:\wamp\www\NEOGETCASH\GESTIONNAIRE\go.php on line 193
Call Stack
# Time Memory Function Location
1 0.0006 727504 {main}( ) ..\go.php:0
( ! ) Notice: Undefined index: data[][code_s] in C:\wamp\www\NEOGETCASH\GESTIONNAIRE\go.php on line 190
Call Stack
# Time Memory Function Location
1 0.0006 727504 {main}( ) ..\go.php:0
D'avance merci pour votre aide.
Partager