";
// Build an array of IDs of all users with pictures in their profiles.
while ($row = mysql_fetch_array($result, MYSQL_NUM)) { // NUM is supposedly faster than ASSOC.
$userIds[] = $row[0];
}
mysql_free_result($result);
// Randomize the ordering of users.
shuffle($userIds);
$numPages = ceil(count($userIds)/($width * $height));
echo "Generating $numPages pages.
";
$count = 0;
for ($page = 1; $page <= $numPages; $page++) {
$file = PROFILE_PATH . "user_gallery_" . $page . ".html";
$descriptor = fopen($file, "w");
page_head("User Picture Gallery: Page $page of $numPages", null, $descriptor);
fwrite($descriptor, "
Browse the user profiles by picture. Only user profiles with pictures are listed here."); fwrite($descriptor, "