You are here: Re: random pic - does not ALWAYS show « PHP Programming Language « IT news, forums, messages
Re: random pic - does not ALWAYS show

Posted by Geoff Berrow on 01/25/07 08:27

Message-ID: <1169688138.621201.85300@a75g2000cwd.googlegroups.com> from
Tobi Hammert contained the following:

><?
> $files = glob("./gfx/zufall/*");
> shuffle ($files);
> if (count($files) < 1)
> $count = count($files);
> else
> $count = 1;
> for ($i = 0; $i < $count; $i ++)
> {
> $file = $files[$i];
> echo "<a href='index.php'><img src='$file' height='341'
>width='634' border='0'></a>";
> }
> ?>
>
>it works fine, just ocasionally, it shows NO pic.
>whats wrong? that is, how can i solve it?

Occasionally you get . or .. in which case you won't see a picture. If
your files are all .jpgs, try $files = glob("./gfx/zufall/*.jpg");
Alternatively try (untested):

$files = glob("./gfx/zufall/*");
shuffle ($files);
foreach( $files as $key=>$value){
if ($value=="." || $value==".."){
unset($files[$key]);
}
}

echo "<a href='index.php'><img src='".$file[0]."' height='341'
width='634' border='0'></a>";
}
?>



--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

 

Navigation:

[Reply to this 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

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