Reply to Re: showing images from a directory

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация