Petit Problème PHP
Harin nyn
Messages postés
24
Date d'inscription
Statut
Membre
Dernière intervention
-
switch01 Messages postés 53 Date d'inscription Statut Membre Dernière intervention -
switch01 Messages postés 53 Date d'inscription Statut Membre Dernière intervention -
Bonsoir,
Je dois faire une liste d'images a partir d'un repertoire. On m'a donné un script à utiliser mais ayant peu de connaissances en programmations je patauge un peu... Pourriez vous m'aider s'il vous plait ?
Voici le script :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sans Titre</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="HAPedit 3.1">
</head>
<body bgcolor="#FFFFFF">
<H2 ALIGN="center">On affiche les images trouvées</H2>
<?php
$dir = opendir(".");
while($file = readdir($dir)) {
if (substr($file,-4)==".jpg" || substr($file,-4)==".gif" || substr($file,-5)==".jpeg" || substr($file,-4)==".png") {
echo "<a href=\"../$file\"><IMG SRC=\"$file\"></a>\n";
}
}
closedir($dir);
?>
</body>
</html>
Que dois je modifier pour l'adapter a ma situation ?
Merci d'avance pour vos réponses !
Je dois faire une liste d'images a partir d'un repertoire. On m'a donné un script à utiliser mais ayant peu de connaissances en programmations je patauge un peu... Pourriez vous m'aider s'il vous plait ?
Voici le script :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sans Titre</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="HAPedit 3.1">
</head>
<body bgcolor="#FFFFFF">
<H2 ALIGN="center">On affiche les images trouvées</H2>
<?php
$dir = opendir(".");
while($file = readdir($dir)) {
if (substr($file,-4)==".jpg" || substr($file,-4)==".gif" || substr($file,-5)==".jpeg" || substr($file,-4)==".png") {
echo "<a href=\"../$file\"><IMG SRC=\"$file\"></a>\n";
}
}
closedir($dir);
?>
</body>
</html>
Que dois je modifier pour l'adapter a ma situation ?
Merci d'avance pour vos réponses !
A voir également:
- Petit Problème PHP
- Easy php - Télécharger - Divers Web & Internet
- Trier du plus petit au plus grand excel - Guide
- Petit 3 ✓ - Forum Word
- Petit 2 ✓ - Forum Windows
- Petit 9 - Forum Mail
1 réponse
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Sans Titre</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="generator" content="HAPedit 3.1"> </head> <body bgcolor="#FFFFFF"> <H2 ALIGN="center">On affiche les images trouvées</H2>
<?php
$dir = opendir("."); //ouverture du repertoire courant -> utilise
//opendir("./img") pr ouvrir le repertoire img...
while($file = readdir($dir)) {
/*readdir($dir) retourne le premier
fichier au premier appel puis quand tu
le rapelle une seconde fois il te
retourne le second fichier et etc...*/
if (substr($file,-4)==".jpg" || substr($file,-4)==".gif" || substr($file,-5)==".jpeg" || substr($file,-4)==".png") {
/*substr recupere dans la chaine de caractere $file le nombre de caractere entré en deuxieme parametre. si ce 2eme parametre est negatif la fonction reupere en commencent par la fin de la chaine*/
echo "<a href='".$file."'><IMG SRC='".$file."'></a>\n";
}
}
closedir($dir);
?>
</body> </html>
voila j'espere avoir été claire et precis ^^
si t'as un pb mon adresse c'est switch_01@hotmail.fr alors hesite pas ! bonne chance a ++