Posted by Mara Guida on 10/23/86 11:34
patrick_woflian wrote:
> [...] i have a list of images in a directory called
> 'pictures'.. and i was hoping to show them on a web page by the
> following code:
<snip>
> but the code doesnt work and ive tried so hard to sort it out.. any one
> able to help????
I've reformatted your code which will let you find one error easily
and added a few comments (the ### lines)
<?php
$handle = opendir('pictures');
if ($handle) {
while (false !== ($file = readdir($handle))) {
### this will match foto5jpg without extension;
### probably you will not have such a filename in the directory
### but you may want to remove the () and escape the .
if (preg_match("/\w+(.jpg)/", $file)) {
### when someone clicks the filename do you want
### them to go to the "pictures" directory?
### AND check your quotes
print "<a href='pictures'>"$file"</a>";
### Why are you printing $file twice?
print "$file <br>";
}
}
closedir($handle);
}
?>
[Back to original message]
|