Simple photo gallery - small change of the code.
Posted: Sun Sep 12, 2010 8:07 pm
I am a fresh PHP programmer. I want to create a simple photo gallery and I even did it, my script displays photos, but there is one problem I cant manage - I do not know how to change the php code to display one photo on one page, so that one can press next button and go to the next photo and so on. Now, my script displays all photos on one page. May anybody tell how to do that ?
Thanks
Code: Select all
<?php
//silhouettes is a folder containing photos
$a = opendir('silhouettes');
$b = readdir($a);
while ($r = readdir($a)){
//check if $r contain ".jpg"
if(strpos("$r",".jpg")){
echo "<img src='silhouettes/".$r."' width='200' height='240' align='center' /><br />";
echo rtrim($r,".jpg");
echo "<br />";
}
}
closedir($a);
?>