par
IVJ9K1E » 15 juin 2011, 21:22
Bonsoir à vous,
je souhaite afficher un album photo, et j'ai crée un tableau dynamique qui affiche les différentes photos dans 3 colonnes.
Mon code :
<TABLE WIDTH="690" CELLSPACING=5>
<?php
$req1 = "SELECT * FROM ".$db_prefix."photo ORDER BY time ASC" or die(mysql_error());
$result1 = mysql_query ($req1);
for($i = 0; $rows1 = mysql_fetch_assoc($result1); ++$i) {
if (preg_match('#^http://[\w-]+[\w.-]+\.[a-zA-Z]{2,6}#i', $rows1['lien_photo'])) { $photo = $rows1['lien_photo']; }
else { $photo = "images/pasimage.png";}
if (($i == 3) OR ($i == 6) OR ($i == 9)) {
echo '<TD width="200"><center><h3>'.$rows1['chantier'].'</h3>
<a href="index.php?mod=alb_det&id'.$rows1['id'].'"><img src="'.$photo.'" width="150"" /></a><br />
<i>'.$rows1['ville'].' - '.$rows1['lieu'].'</i></center></TD></TR>';}
elseif (($i == 1) OR ($i == 4) OR ($i == 7)) {
echo'<TR><TD width="200"><center><h3>'.$rows1['chantier'].'</h3>
<a href="index.php?mod=alb_det&id'.$rows1['id'].'"><img src="'.$photo.'" width="150"" /></a><br />
<i>'.$rows1['ville'].' - '.$rows1['lieu'].'</i></center></TD>'; }
elseif (($i == 2) OR ($i == 5) OR ($i == 8)) {
echo '<TD width="200"><center><h3>'.$rows1['chantier'].'</h3>
<a href="index.php?mod=alb_det&id'.$rows1['id'].'"><img src="'.$photo.'" width="150"" /></a><br />
<i>'.$rows1['ville'].' - '.$rows1['lieu'].'</i></center></TD>'; }
}
?>
</table>
Ma question : ce tableau je l'ai fait lorsque j'ai dans ma requete SQL un limit 0, 10
mais là je souhaite afficher les photos sans limit, et que le script sache quand mettre un <tr> ou <\tr>.
Je ne sais pas si je suis clair.
Merci de votre patience.
Bonsoir à vous,
je souhaite afficher un album photo, et j'ai crée un tableau dynamique qui affiche les différentes photos dans 3 colonnes.
Mon code :
[php]
<TABLE WIDTH="690" CELLSPACING=5>
<?php
$req1 = "SELECT * FROM ".$db_prefix."photo ORDER BY time ASC" or die(mysql_error());
$result1 = mysql_query ($req1);
for($i = 0; $rows1 = mysql_fetch_assoc($result1); ++$i) {
if (preg_match('#^http://[\w-]+[\w.-]+\.[a-zA-Z]{2,6}#i', $rows1['lien_photo'])) { $photo = $rows1['lien_photo']; }
else { $photo = "images/pasimage.png";}
if (($i == 3) OR ($i == 6) OR ($i == 9)) {
echo '<TD width="200"><center><h3>'.$rows1['chantier'].'</h3>
<a href="index.php?mod=alb_det&id'.$rows1['id'].'"><img src="'.$photo.'" width="150"" /></a><br />
<i>'.$rows1['ville'].' - '.$rows1['lieu'].'</i></center></TD></TR>';}
elseif (($i == 1) OR ($i == 4) OR ($i == 7)) {
echo'<TR><TD width="200"><center><h3>'.$rows1['chantier'].'</h3>
<a href="index.php?mod=alb_det&id'.$rows1['id'].'"><img src="'.$photo.'" width="150"" /></a><br />
<i>'.$rows1['ville'].' - '.$rows1['lieu'].'</i></center></TD>'; }
elseif (($i == 2) OR ($i == 5) OR ($i == 8)) {
echo '<TD width="200"><center><h3>'.$rows1['chantier'].'</h3>
<a href="index.php?mod=alb_det&id'.$rows1['id'].'"><img src="'.$photo.'" width="150"" /></a><br />
<i>'.$rows1['ville'].' - '.$rows1['lieu'].'</i></center></TD>'; }
}
?>
</table>[/php]
Ma question : ce tableau je l'ai fait lorsque j'ai dans ma requete SQL un limit 0, 10
mais là je souhaite afficher les photos sans limit, et que le script sache quand mettre un <tr> ou <\tr>.
Je ne sais pas si je suis clair.
Merci de votre patience.