Created
February 21, 2012 07:35
-
-
Save ZachMoreno/1874861 to your computer and use it in GitHub Desktop.
Pagination
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function pagination () | |
{ | |
$per_page = 16; | |
$pages_query = mysql_query ("SELECT 'file_id' FROM 'imagefiles' LIMIT $star, $per_page"); | |
$pages = ceil(mysql_result($pages_query, 0) / $per_page); | |
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; | |
$start = ($page - 1) * $page; | |
if ($pages >= 1 && $page <= $pages) | |
{ | |
for ($x = 1; $x <= $pages; $x++) | |
{ | |
echo ($x == $page) ? "<strong><a href='?page=.$x.'>'.$x.'</a> </strong>" : "<a href='?page=.$x.'>'.$x.'</a> "; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment