Défilement photo en php
phinou
-
SoUsOu -
SoUsOu -
Bonjour,
J'essaye de faire défiler des photos grâce à ce code...
Je récupère un id d'une page précédente pour avoir le bon fichier...mais le problème vient du fait qu'aucune photo ne veut apparaître alors que le nombre de photos qu'affiche le programme est correct...
<?php
//je récupère l'id de la rubrique
$idgal=$_POST['id'];
//nom du répertoire contenant les images à afficher
$nom_repertoire = "galerie/sport/$idgal";
// extensions acceptées
$extensions_ok = array("jpg","gif","png","jpeg", "JPG", "GIF", "PNG", "JPEG");
//on ouvre le repertoire
$dossier = opendir($nom_repertoire);
$i = 0;
$photos = array();
//on les stocke les noms de fichiers images dans un tableau
while ($fichier = readdir($dossier))
{
if(in_array(strtolower(substr($fichier, -3)),$extensions_ok))
$photos[] = $fichier;
}
//on ferme le répertoire
closedir($dossier);
//on peut trier le tableau par ordre alphabétique:
// array_multisort($photos, SORT_ASC);
$count_photos = count($photos);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Slideshow</title>
</head>
<body>
<form name="slideform" action="" id="slideform" style="margin:0px">
<table width="100%" >
<tr>
<td nowrap="nowrap">
<b>Il y a <?php echo $count_photos; ?></b> Photo<?php echo (($count_photos>1)? "s": ""); ?>
<select name="slide" onchange="change();">
<?php
for($i=0; $i < count($photos); $i++)
echo "<option value=\"".$photos[$i]."\" ".(($i==0)? "selected=\"selected\"" : ""). ">- ".($i+1)." -</option>";
?>
</select>
</td>
<td nowrap="nowrap" align="right">
<input type="button" onclick="previous();" value="«" title="Précédente" />
<input type="button" onclick="ap(this.value);" name="slidebutton" value=" > " title="Défilement Automatique" />
<input type="button" onclick="next();" value="»" title="Suivante" /></td>
</tr>
</table>
</form>
<table width="100%" >
<tr>
<td colspan="2" align="center" width="100%">
<img alt="" src="<?php echo $photos['0']; ?>" id="show" />
</td>
</tr>
</table>
</body>
</html>
J'essaye de faire défiler des photos grâce à ce code...
Je récupère un id d'une page précédente pour avoir le bon fichier...mais le problème vient du fait qu'aucune photo ne veut apparaître alors que le nombre de photos qu'affiche le programme est correct...
<?php
//je récupère l'id de la rubrique
$idgal=$_POST['id'];
//nom du répertoire contenant les images à afficher
$nom_repertoire = "galerie/sport/$idgal";
// extensions acceptées
$extensions_ok = array("jpg","gif","png","jpeg", "JPG", "GIF", "PNG", "JPEG");
//on ouvre le repertoire
$dossier = opendir($nom_repertoire);
$i = 0;
$photos = array();
//on les stocke les noms de fichiers images dans un tableau
while ($fichier = readdir($dossier))
{
if(in_array(strtolower(substr($fichier, -3)),$extensions_ok))
$photos[] = $fichier;
}
//on ferme le répertoire
closedir($dossier);
//on peut trier le tableau par ordre alphabétique:
// array_multisort($photos, SORT_ASC);
$count_photos = count($photos);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Slideshow</title>
</head>
<body>
<form name="slideform" action="" id="slideform" style="margin:0px">
<table width="100%" >
<tr>
<td nowrap="nowrap">
<b>Il y a <?php echo $count_photos; ?></b> Photo<?php echo (($count_photos>1)? "s": ""); ?>
<select name="slide" onchange="change();">
<?php
for($i=0; $i < count($photos); $i++)
echo "<option value=\"".$photos[$i]."\" ".(($i==0)? "selected=\"selected\"" : ""). ">- ".($i+1)." -</option>";
?>
</select>
</td>
<td nowrap="nowrap" align="right">
<input type="button" onclick="previous();" value="«" title="Précédente" />
<input type="button" onclick="ap(this.value);" name="slidebutton" value=" > " title="Défilement Automatique" />
<input type="button" onclick="next();" value="»" title="Suivante" /></td>
</tr>
</table>
</form>
<table width="100%" >
<tr>
<td colspan="2" align="center" width="100%">
<img alt="" src="<?php echo $photos['0']; ?>" id="show" />
</td>
</tr>
</table>
</body>
</html>
A voir également:
- Défilement photo en php
- Google photo - Télécharger - Albums photo
- Photo filtre 7 gratuit - Télécharger - Retouche d'image
- Google maps photo maison - Guide
- Barre de défilement - Guide
- Partage photo - Guide