";
// 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);
if (count($userIds) > 0) {
// Randomize the ordering of users.
shuffle($userIds);
}
$numPages = ceil(count($userIds)/($width * $height));
// Make sure that a page is generated even when no profiles with pictures
// exist in order to avoid 404 errors from the profile_menu page.
if ($numPages == 0) {
$numPages = 1;
}
//echo "Generating $numPages pages.
";
$count = 0;
for ($page = 1; $page <= $numPages; $page++) {
$file = "../html_user/" . 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, "