note 7946 added to readdir

From: Date: Mon, 21 Aug 2000 18:12:01 +0000
Subject: note 7946 added to readdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-2902@lists.php.net to get a copy of this message
i have some problem with this code.. i know that there is a total of 169 images in 52 dirs, and the difrent dirs are passed om by a mysql guery, but i rarely get that result from this code. sometimes i get 114 images in total sometimes i get 145 and so on.. this script also writes out how many images there is in each dir and in many occations it says 0 images, thereof the total result varies to as i mentioned earlier. does anyone know why this is? how come i get diffrent results every time i update the page, im a beginner at php so please help me. --code--starts-- while ($row = mysql_fetch_array($result)){ $count = 0; $handle = opendir("bilder/$row[mapp]") // opens the dir from where to retrive te jpg images. or die ("error"); while (false!==($file = readdir($handle))) { if (eregi(".jpg",$file)) { $count++; } } echo "\t<tr>\n"; <td bgcolor=\"white\">"; echo "<font size=\"2\" face=\"arial\">"; echo "$count</font></td>\n"; closedir($handle);//closes the directory $totalt = $count + $totalt; } --code--ends-- i have removed some "unessesary" code. thank you / Björn http://www.php.net/manual/function.readdir.php

« previous php.notes (#2902) next »