$total_count = mysql_result($total_count, 0); $pagination = new Pagination($page, $per_page, $total_count); // Instead of finding all records, just find the records // for this page $sql = "SELECT * FROM photographs "; $sql .= "WHERE category = '{$category}' "; $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 .= "WHERE category = '{$category}' "; $sql2 .= "ORDER BY `photographs2`.`id` DESC "; $sql2 .= "LIMIT {$per_page} "; $sql2 .= "OFFSET {$pagination->offset()}"; $photos2 = Photograph2::find_by_sql($sql2); //$sql3 ="UPDATE photographs SET likes = likes + 1 where id ='28'"; //$sql3 ="SELECT likes FROM photographs where id ='28'"; //$likesomething = Photograph::find_all($sql3,0); // Need to add ?page=$page to all links we want to // maintain the current page (or store $page in $session) ?> <?php include 'indexPictureArea.php'; ?> <br><br> <div id="pagination" style="clear: both;"><center> <?php if ($pagination->total_pages() > 1) { if ($pagination->has_previous_page()) { echo "<a id='previousPage' href=\"categoryQuery.php?category={$category}&page=";