My readdir in a while statment doesn't work.
Posted: Sat Mar 15, 2003 11:58 am
<?php do {
........mySQL code here calling up a table row according to $pkcount.......
while(($file = readdir($dir)) !== false) {
if ($Player['pick'.$pkcount].'.jpg' == $file)
{$iconpic = $Player['pick'.$pkcount].'.jpg'; closedir($dir); break;}
else {$iconpic = "non.gif";}
}
............more code here, including img src=$iconpic.........
++$pkcount;
} while ($pkcount < 21); ?>
This works if my outter do/while statement only runs once. But if I set the do/while to anything higher the php just sits.
Is it valid to use a closedir and then loop around and "reddir" the same directory?
I have approx. 400 small icon files in a directory. I am trying to check if there is no icon match available it sets the current $iconpic = non.gif, right before an img src=$iconpic right outside of the "while"
I am looking for the most efficeint way to search each of 20 names in a database against 400 filenames in a directory. This could result in approx. 8000 file name reads. Is this partical? Or too hig?
........mySQL code here calling up a table row according to $pkcount.......
while(($file = readdir($dir)) !== false) {
if ($Player['pick'.$pkcount].'.jpg' == $file)
{$iconpic = $Player['pick'.$pkcount].'.jpg'; closedir($dir); break;}
else {$iconpic = "non.gif";}
}
............more code here, including img src=$iconpic.........
++$pkcount;
} while ($pkcount < 21); ?>
This works if my outter do/while statement only runs once. But if I set the do/while to anything higher the php just sits.
Is it valid to use a closedir and then loop around and "reddir" the same directory?
I have approx. 400 small icon files in a directory. I am trying to check if there is no icon match available it sets the current $iconpic = non.gif, right before an img src=$iconpic right outside of the "while"
I am looking for the most efficeint way to search each of 20 names in a database against 400 filenames in a directory. This could result in approx. 8000 file name reads. Is this partical? Or too hig?