Registered Users'; require_once ('../mysqli_connect.php'); // Number of records to show per page: $display = 10; // Determine how many pages there are... if (isset($_GET['p']) && is_numeric($_GET['p'])) { // Already been determined. $pages = $_GET['p']; } else { // Need to determine. // Count the number of records: $q = "SELECT COUNT(user_id) FROM users"; $r = @mysqli_query ($dbc, $q); $row = @mysqli_fetch_array ($r, MYSQLI_NUM); $records = $row[0]; // Calculate the number of pages... if ($records > $display) { // More than 1 page. $pages = ceil ($records/$display); } else { $pages = 1; } } // End of p IF. // Determine where in the database to start returning results... if (isset($_GET['s']) && is_numeric($_GET['s'])) { $start = $_GET['s']; } else { $start = 0; } // Determine the sort... // Default is by registration date. $sort = (isset($_GET['sort'])) ? $_GET['sort'] : 'rd'; // Determine the sorting order: switch ($sort) { case 'ln': $order_by = 'last_name ASC'; break; case 'fn': $order_by = 'first_name ASC'; break; case 'rd': $order_by = 'registration_date ASC'; break; default: $order_by = 'registration_date ASC'; $sort = 'rd'; break; } // Make the query: $q = "SELECT last_name, first_name, DATE_FORMAT(registration_date, '%M %d, %Y') AS dr, user_id FROM users ORDER BY $order_by LIMIT $start, $display"; $r = @mysqli_query ($dbc, $q); // Run the query. // Table header: echo ' '; // Fetch and print all the records.... $bg = '#eeeeee'; while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); echo ' '; } // End of WHILE loop. echo '
Edit Delete Last Name First Name Date Registered
Edit Delete ' . $row['last_name'] . ' ' . $row['first_name'] . ' ' . $row['dr'] . '
'; mysqli_free_result ($r); mysqli_close($dbc); // Make the links to other pages, if necessary. if ($pages > 1) { echo '

'; $current_page = ($start/$display) + 1; // If it's not the first page, make a Previous button: if ($current_page != 1) { echo 'Previous '; } // Make all the numbered pages: for ($i = 1; $i <= $pages; $i++) { if ($i != $current_page) { echo '' . $i . ' '; } else { echo $i . ' '; } } // End of FOR loop. // If it's not the last page, make a Next button: if ($current_page != $pages) { echo 'Next'; } echo '

'; // Close the paragraph. } // End of links section. include ('includes/footer.html'); ?>