Código PHP:
<?php
/*
First get total number of rows in data table.
If you have a WHERE clause in your query, make sure you mirror it here.
*/
include('confgk/db_xsaacon.php');
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$query = "SELECT COUNT(*) as num FROM `like`";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$limit = '23';
/* Setup vars for query. */
$targetpage = "top.php";
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
/* Get data. */
$resultst = mysql_query("SELECT * FROM `like` ORDER BY count DESC LIMIT $start,$limit");
/* Setup page vars for display. */
if ($page == 0) $page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
?>