Skip to content

Instantly share code, notes, and snippets.

@ZachMoreno
Created February 21, 2012 07:35
Show Gist options
  • Save ZachMoreno/1874861 to your computer and use it in GitHub Desktop.
Save ZachMoreno/1874861 to your computer and use it in GitHub Desktop.
Pagination
<?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