Bonsoir à tous,
Je suis devant un problème où je n'ai absolument aucune explication :
J'ai un form tout simple :
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
| <form name="maj_ldt" method="post" action="patient.php">
<ul id="sortable">
<?php
$i=0;
$sql = "SELECT * FROM neuro_event WHERE patient_id = '".$_SESSION['dmu']."' ORDER BY position ASC";
echo $sql;
$req = mysql_query($sql) or die(mysql_error());
while($d = mysql_fetch_assoc($req)){
$i++;
?>
<li <?php echo 'id="exam_'.$i.'"'; ?> >
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<?php $examen = explode("_",$d['content_type_id']); ?>
<input type="hidden" name="category[<?php echo $i; ?>][id]" value="<?php echo $d["id"]; ?>"/>
<input type="hidden" name="category[<?php echo $i; ?>][patient_id]" value="<?php echo $d["patient_id"]; ?>"/>
<input type="text" name="category[<?php echo $i; ?>][event_date]" disabled="disabled" value="<?php echo $d["event_date"]; ?>"/>
<input type="hidden" name="category[<?php echo $i; ?>][content_type_id]" value="<?php echo $d["content_type_id"]; ?>"/>
<input type="hidden" class="positionInput" name="category[<?php echo $i; ?>][position]" value="<?php echo $d["position"]; ?>"/>
</li>
<?php
}
?>
</ul>
<input type="submit" value="Enregistrer"/>
</form> |
Qui fait appel à la même page pour être traité avec ce code :
1 2 3 4 5 6 7 8 9
| if(!empty($_POST)){
$cat = $_POST["category"];
foreach( $cat as $c){
extract($c);
$sql = "UPDATE neuro_event SET patient_id='$patient_id', content_type_id = '$content_type_id', event_date = '$event_date', position=$position WHERE id=$id";
echo $sql;
//mysql_query($sql) or die(mysql_error());
}
} |
Le foreach ne reçoit pas un champ
celui-ci :
<input type="text" name="category[<?php echo $i; ?>][event_date]" disabled="disabled" value="<?php echo $d["event_date"]; ?>"/>
J'ai cet avertissement :
Notice: Undefined variable: event_date in C:\Program Files (x86)\EasyPHP-5.3.6.0\www\Neuro\patient.php on line 11
Si je mets un simple var_dump, j'ai ceci :
array
'category' =>
array
2 =>
array
'id' => string '178' (length=3)
'patient_id' => string '20010102FG02' (length=12)
'content_type_id' => string 'irm_20010102FG02_178' (length=20)
'position' => string '1' (length=1)
1 =>
array
'id' => string '170' (length=3)
'patient_id' => string '20010102FG02' (length=12)
'content_type_id' => string 'irm_20010102FG02_170' (length=20)
'position' => string '1' (length=1)
J'ai vérifié avec Firebug, l'input event_date est généré sur la page HTML
là, je sèche... auriez-vous une idée ?
Merci d'avance.
beegees
Partager