<html> <head> <title>Home</title> <?php require "links.php"; ?> </head> <body> <?php // 1. the current page number ($current_page) $page = !empty($_GET['page']) ? (int) $_GET['page'] : 1; // 2. records per page ($per_page) $per_page = 1; // 3. total record count ($total_count) $total_count = Photograph::count_all(); $total_count2 = Photograph2::count_all(); // Find all photos // use pagination instead //$photos = Photograph2::find_all(); $pagination = new Pagination($page, $per_page, $total_count2); // Instead of finding all records, just find the records // for this page $sql = "SELECT * FROM photographs "; $sql .= "ORDER BY `photographs`.`id` DESC "; $sql .= "LIMIT {$per_page} "; $sql .= "OFFSET {$pagination->offset()}"; $photos = Photograph::find_by_sql($sql); $sql2 = "SELECT * FROM photographs2 "; $sql2 .= "ORDER BY `photographs2`.`id` DESC "; $sql2 .= "LIMIT {$per_page} "; $sql2 .= "OFFSET {$pagination->offset()}";