Bonjour

Je débute en php et j'aimerai afficher des images sur 3 lignes et 5 colonnes :

a b c d e
f g h i j
k l m n o

J'ai fait le code suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
 
$limit = '0';
$rq_photo = "SELECT * FROM photo LIMIT $limit,5";
echo "SELECT * FROM photo LIMIT '$limit'";
$resultat_photo = mysql_query($rq_photo);
 
echo '<table><tr>';
 
while ($photo = mysql_fetch_array($resultat_photo))
 
	{
 
	echo '<td><img  class="img" src="image/';
	echo $photo["photo_id"].'.jpg" /></td>';
 
	}
 
	echo '</tr><tr>';
 
$limit = $limit+5;
$rq_photo = "SELECT * FROM photo LIMIT $limit,5";
$resultat_photo = mysql_query($rq_photo);
 
while ($photo = mysql_fetch_array($resultat_photo))
 
	{
 
	echo '<td><img  class="img" src="image/';
	echo $photo["photo_id"].'.jpg" /></td>';
 
	}
 
	echo '</tr><tr>';
 
$limit = $limit+5;
$rq_photo = "SELECT * FROM photo LIMIT $limit,5";
$resultat_photo = mysql_query($rq_photo);
 
while ($photo = mysql_fetch_array($resultat_photo))
 
	{
 
	echo '<td><img  class="img" src="image/';
	echo $photo["photo_id"].'.jpg" /></td>';
 
	}
 
	echo '</tr></table>';
ça fonctionne bien par contre je suis sur qu'on peut faire beaucoup plus simple et éviter de répéter plusieurs fois certaines lignes comme je l'ai fait.

Ensuite je prévois de faire une pagination mais je suis pas sur que je me soit simplifié la tache de la maniere dont j'ai traité le probleme.

Si vous pouviez m'aider à simplifier mon code merci