<?php
$sql = "SELECT * FROM ".$_GET['liasse']." where n_doss='".mysql_real_escape_string($_GET['n_doss'])."' AND date_action < now()";
$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
?><?php if (isset($row['date_action']) AND $row['date_action'] < date("Y-m-d")) { ?>
<table bordercolor="#FF0033" border="1" style="border-style:dashed; background-repeat:no-repeat; background-position:left" background="images/passif.png" ><tr><td> <p> </p>
<p> </p>
<p> </p>
</td></tr>
<tr>
<td><strong>CODE S</strong></td>
<td><strong>LIBELLE</strong></td>
<td><strong>ACTION</strong></td>
<td><strong>DESCRIPTION</strong></td>
<td><strong>DATE</strong></td><td><strong>ACTIONS</strong></td>
</tr>
<form action="<?php echo (isset($_POST['go'])) ? 'go2.php' : '#'; ?>" method="post">
<input type="hidden" name="liasse" value="<?php echo $_GET['liasse']; ?>"/>
<input type="hidden" name="n_doss" value="<?php echo $_GET['n_doss']; ?>"/>
<?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; ?>][libelle]" type="text" value="<?php echo $row['libelle']; ?>" 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['description']; ?>" size="55"></td>
<td><input type="text" name="data[<?php echo $i; ?>][date]" value="<?php $jours = date('d-m-Y',strtotime($row['date_action'])) ; echo $get_date($jours) ; ?>" size="12"></td>
<td nowrap><img src="images/gtk-edit.png" width="24" height="24"> <img src="images/plus.png" width="24" height="24"> <img src="images/eraser.png" width="24" height="24"></td>
</tr>
<?php endwhile; ?></td></tr></table> </td>
</tr>
</table><?php } ?> car en fait j'ai un if et un while, j'ai essayé de les imbriquer les un dans les autres, le while est positionné de telle sorte que seul les lignes du tableau sont dupliquées et si j’inclus le if dans le while alors le tableau est dupliqué (ce que je ne souhaites pas), mais comme présentement j'ai pas trouvé d'issu et que la variable row qui est testée dans le isset n'existe pas alors rien ne s'exécute, je ne sais pas comment utiliser une variable créée par un while avant et si je fais deux while alors tous mes tableaux seront dupliqués, ce que je ne souhaites pas. d'avance merci pour votre aide.