par
Ryle » 10 janv. 2007, 18:27
Bah il est très bien ce code.... y a pas grand chose à redire
Eventuellement, tu peux simplifier les 3 premiers if() (le 3ème étant le même que le 1er pour le cas ou $limite est à 0)
$limite = isset($_GET['limite']) ? $_GET['limite'] : 0;
if (is_numeric($limite) && $limite+$nombre < $total) {
$suivant = $limite + $nombre;
echo '<a href="'.$_SERVER['PHP_SELF'].'?limite='.$suivant.'">Suivant</a>';
}
if (is_numeric($limite) && $limite > 0) {
$precedent = $limite - $nombre;
echo '<a href="'.$_SERVER['PHP_SELF'].'?limite='.$precedent.'">Précédent</a>';
}
Et personnellement, quand j'ai une grosse quantité de html, je préfère sortir du php, mais c'est pas obligatoire :
<?php
while ($array = mysql_fetch_array($query)){
?>
<tr>
<td width="900">Commentaire n°<?php echo $array['id'];?></td>
</tr>
<tr>
<td widht="900">
<table width="900" border="0" cellspacing="0" cellpading="0">
<tr>
<td width="150">Nom : <?php echo $array['pseudo'];?></td>
<td width="750">Mail : <?php echo $array['mail'];?></td>
</tr>
</table>
</td>
<tr>
<td width="900">Message : <?php echo $array['message'];?></td>
</tr>
<tr>
<td height="15"></td>
</tr>
<?php
}
?>
Tu n'es pas obligé non plus de mettre du width="900" partout (t'as d'ailleurs un "
widht" qui traine

). Le simple fait d'avoir tes deux cellules à 150 et 750 imposera automatiquement une taille de 900px à tout le reste du tableau

Bah il est très bien ce code.... y a pas grand chose à redire :)
Eventuellement, tu peux simplifier les 3 premiers if() (le 3ème étant le même que le 1er pour le cas ou $limite est à 0)
[php]$limite = isset($_GET['limite']) ? $_GET['limite'] : 0;
if (is_numeric($limite) && $limite+$nombre < $total) {
$suivant = $limite + $nombre;
echo '<a href="'.$_SERVER['PHP_SELF'].'?limite='.$suivant.'">Suivant</a>';
}
if (is_numeric($limite) && $limite > 0) {
$precedent = $limite - $nombre;
echo '<a href="'.$_SERVER['PHP_SELF'].'?limite='.$precedent.'">Précédent</a>';
} [/php]
Et personnellement, quand j'ai une grosse quantité de html, je préfère sortir du php, mais c'est pas obligatoire :
[php]<?php
while ($array = mysql_fetch_array($query)){
?>
<tr>
<td width="900">Commentaire n°<?php echo $array['id'];?></td>
</tr>
<tr>
<td widht="900">
<table width="900" border="0" cellspacing="0" cellpading="0">
<tr>
<td width="150">Nom : <?php echo $array['pseudo'];?></td>
<td width="750">Mail : <?php echo $array['mail'];?></td>
</tr>
</table>
</td>
<tr>
<td width="900">Message : <?php echo $array['message'];?></td>
</tr>
<tr>
<td height="15"></td>
</tr>
<?php
}
?>[/php]Tu n'es pas obligé non plus de mettre du width="900" partout (t'as d'ailleurs un "[i]widht[/i]" qui traine ;)). Le simple fait d'avoir tes deux cellules à 150 et 750 imposera automatiquement une taille de 900px à tout le reste du tableau :)