par
Cyrano » 15 mars 2008, 00:18
Normal : tu as mis la fonction dans la boucle donc à chaque tour ça redéclare la même fonction... tout à fait inutilement.
Proposition de correction :
<?php
function DateMysqltoFr($DateMysql , $conv='fr')
{
switch($conv)
{
case 'fr':
list($annee, $mois, $jour) = explode("-", $DateMysql);
return ($jour."/".$mois."/".$annee);
break;
case 'mysql':
list($jour, $mois, $annee) = explode("/", $DateMysql);
return ($annee."-".$mois."-".$jour);
break;
} // switch
}
do {
?>
<tr>
<td><?php echo $row_listeventes['id']; ?></td>
<td><?php echo $row_listeventes['nom']; ?></td>
<td><?php echo $row_listeventes['adresse']; ?></td>
<td><?php echo $row_listeventes['nature']; ?></td>
<td><?php echo DateMysqltoFr($row_listeventes['ddebut']); ?></td>
<td><?php echo DateMysqltoFr($row_listeventes['dfin']); ?></td>
<td><?php echo $row_listeventes['motif']; ?></td>
</tr>
<?php
} while ($row_listeventes = mysql_fetch_assoc($listeventes));
mysql_free_result($listeventes);
?>
</table>
<p> </p>
<p> </p>
</body>
</html>
Normal : tu as mis la fonction dans la boucle donc à chaque tour ça redéclare la même fonction... tout à fait inutilement.
Proposition de correction :
[php]<?php
function DateMysqltoFr($DateMysql , $conv='fr')
{
switch($conv)
{
case 'fr':
list($annee, $mois, $jour) = explode("-", $DateMysql);
return ($jour."/".$mois."/".$annee);
break;
case 'mysql':
list($jour, $mois, $annee) = explode("/", $DateMysql);
return ($annee."-".$mois."-".$jour);
break;
} // switch
}
do {
?>
<tr>
<td><?php echo $row_listeventes['id']; ?></td>
<td><?php echo $row_listeventes['nom']; ?></td>
<td><?php echo $row_listeventes['adresse']; ?></td>
<td><?php echo $row_listeventes['nature']; ?></td>
<td><?php echo DateMysqltoFr($row_listeventes['ddebut']); ?></td>
<td><?php echo DateMysqltoFr($row_listeventes['dfin']); ?></td>
<td><?php echo $row_listeventes['motif']; ?></td>
</tr>
<?php
} while ($row_listeventes = mysql_fetch_assoc($listeventes));
mysql_free_result($listeventes);
?>
</table>
<p> </p>
<p> </p>
</body>
</html>[/php]