Posted by jamen on 11/20/58 11:29
Davide wrote:
> Hi all.
>
> With this simple script I can see all my jpg in a web page..
> but they are confused randomly in the page.
> <?php
> if ($handle = opendir('/cover')) {
> while (false !== ($file = readdir($handle))) {
> if (($file != "." && $file != "..")) {
> echo " <img src=\"cover/$file\" alt=\"$file\" border=0> ";
> }
> }
> closedir($handle);
> }
>
> ?>
>
Put all the files in an array and sort it, then print
$files = array();
if (($file != "." && $file != "..")) {
$files[] = $file
}
all done:
asort($files);
for each($files as $file){
echo " <img src=\"cover/$file\" alt=\"$file\" border=0> ";
}
Navigation:
[Reply to this message]
|