Comment afficher des photos par lots

pascal -  
 pascal -
Bonjour,

J'essaie désespérément de faire apparaître des photos par max 4 sur un page en reprenant des informations d'une base de donnée mais je n'y arrive pas vraiment. Il y a un ou deux nouveaux paramètres que je donne dans le code de ma page mais il semble que ça ne joue pas tout à fait.

Est-ce que qqn peut m'aider ou me dire s'il existe un code qq part qui fait cette action?

Merci beaucoup.

Pascal
A voir également:

4 réponses

philaz Messages postés 1027 Statut Contributeur 235
 
Hello, est-ce que tu parles de HTML, de PHP, Sgbd mySQL ?
Il faudrait que tu en dises un peu plus quand même ... :-))
0
pascal
 
Hello,

Alors, comme j'avais oublié de préciser, je parle de PHP. Je récupère les données d'une base Mysql mais je n'ai pas le compteur dans la base, il faut donc que je le rajoute pour ma boucle.

Pascal
0
teebo Messages postés 33570 Date d'inscription   Statut Modérateur Dernière intervention   1 793
 
Salut,
Il te faut un compteur mais en PHP c'est pas dur, ou est ton probleme?

.  .  Bon!Si on m'empeche de travailler
\_/  Je ne me debattrai pas!
0
pascal
 
Ouaip,

J'ai bien mis un compteur dans mon code mais il semble qu'il ne fonctionne pas... et comme je suis un véritable débutant, c'est pas simple de m'y retrouver pour voir ce qui manque.

Voici mon code :

<html>
<head>
<?
include ("./include/global.php");

$connection = mysql_connect($host,$user,$password)
or die ("Connection au serveur impossible");
$db = mysql_select_db($database,$connection)
or die ("Sélection de la base de données impossible");

// Variables pour l'affichage

$id_lieux2="{$_REQUEST['lieux']}";
if(!isset($firstrecord)) $firstrecord=0;

// Sélection du lieux préselectionné
$query = "SELECT * FROM tb_lieux INNER JOIN tb_photos ON tb_lieux.id_lieux=tb_photos.id_lieux WHERE tb_lieux.id_lieux='$id_lieux2' ORDER BY id_pic ASC LIMIT $firstrecord , 5";

// echo "$query";

$r_listephotos=mysql_query($query)
or die ("Comptage des photos pas possible");

// echo "$r_listephotos";
?>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/monsite.css" rel="stylesheet" type="text/css">
</head>

<script language="JavaScript" src="./script/script.js"></script>
<script language="JavaScript" src="./script/opt_scroller.js"></script>
<!-- <script language="JavaScript" src="./script/search.js"></script> -->

<body bgcolor=#0C419A leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<? echo $_REQUEST["firstrecord"]; ?>
<table width="760" align="center" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="760" height="90" valign="top">
<table width="750" height="90" valign="top" align="left" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="150" rowspan="3" valign="top" bgcolor="#0C419A"><a href="photos.php?lieux=PER0"><img src="./img/OZmap_small.gif" width="150" height="90" border="0"></a></td>
<td width="90" height="30" valign="top" class="Navigation">Perth</td>
<td width="90" height="30" valign="top" class="Navigation"><a href="photos.php?lieux=ULU0&firstrecord=0">Uluru</a></td>
<td width="90" height="30" valign="top" class="Navigation"><a href="photos.php?lieux=KAT0&firstrecord=0">Kata
Tjuta</a></td
><td width="90" height="30" valign="top" class="Navigation"><a href="photos.php?lieux=KAK0&firstrecord=0">Kakadu</a></td>
<td width="90" height="30" valign="top" class="Navigation"><a href="photos.php?lieux=MEL0&firstrecord=0" class="Navigation">Melbourne</a></td>
<td width="150" rowspan="3" valign="top" bgcolor="#0C419A" class="Navigation">
<a href="../Index.htm">Retour à la page <br>
d'entrée du site.</a></td>
</tr>
<tr>
<td width="90" height="30" valign="top" class="Navigation"><a href="photos.php?lieux=CAN0&firstrecord=0">Canberra</a></td>
<td width="90" height="30" valign="top" class="Navigation"><a href="photos.php?lieux=SYD0&firstrecord=0">Sydney</a></td>
<td width="90" height="30" valign="top" class="Navigation"><a href="photos.php?lieux=SYD1&firstrecord=0">Sydney
2000 Olympics</a></td>
<td width="90" height="30" valign="top" class="Navigation">Brisbane</td>
<td width="90" height="30" valign="top" class="Navigation"><a href="photos.php?lieux=FRA0&firstrecord=0">Fraser
Island</a></td>
</tr>
<tr>
<td width="90" height="30" valign="top" class="Navigation">Cairns</td>
<td width="90" height="30" valign="top" class="Navigation"><a href="photos.php?lieux=COR0&firstrecord=0">Grande
barrière de Corail</a></td>
<td width="90" height="30" valign="top"><!--DWLayoutEmptyCell--> </td>
<td width="90" height="30" valign="top"><!--DWLayoutEmptyCell--> </td>
<td width="90" height="30" valign="top" class="Navigation"><a href="mailto:pascal_oz@bluewin.ch">Contacte-moi</a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="21" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="760" height="21"> </td>
</tr>
</table>
<table border='0' align='center' cellpadding='5' cellspacing='0' bgcolor='#0C419A'>
<tr>
<?
if(mysql_num_rows($r_listephotos)>0)
{
$photoscounter=0;
while($rowphotos=mysql_fetch_object($r_listephotos) AND $photoscounter<4)
{
$photoscounter++;

?>
<!-- Ici, on fait apparaître les photos du lieux sélectionné en ligne -->
<td width="180"><img src="<?=$rowphotos->ph_img_pte?>" width="180" border="0"><p align="center"> <?=$rowphotos->li_region?> - <?=$rowphotos->li_navigation?></p></td>
<?
}
?>

</tr>
</table>
<table width="760" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="20" height="21">
<?
if ($_REQUEST["firstrecord"]>0)
{
?>
<div id="left" style="width:11px; height:10px; z-index:2"> <a href="photos.php?lieux=<?=$id_lieux2?>&firstrecord=<?=$_REQUEST["firstrecord"]-4?>">
<img src="./img/common/pointer/left.gif" width="10" height="10" border="0">
</a> </div>
<?
}
?>
</td>
<td width="720" height="21"> </td>
<td width="20" height="21">
<?
if(mysql_num_rows($r_listephotos)==5)
{
?>
<div id="right" style="width:13px; height:7px; z-index:3">
<a href="photos.php?lieux=<?=$id_lieux2?>&firstrecord=<?=$_REQUEST["firstrecord"]+4?>">
<img src="./img/common/pointer/right.gif" width="10" height="9" border="0">
</a>
</div>
<?
}
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="597"> </td>
</tr>
<?
}
?>
</table>
</body>
</html>

Salut.

Pascal
0