For some reason I can't figure out how to use that one!!
What I used before I asked was the following:
if(!isset($_GET['pages']))
{
$pages = 1;
}
else
{
$pages = $_GET['pages'];
}
$max_results = 20;
$from = (($pages * $max_results) - $max_results);
$sql = "SELECT ip, count(*) AS hits FROM `simplecount` GROUP BY ip ORDER BY `hits` desc, ip asc LIMIT $from, $max_results";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
echo ".... all the output!!";
}
The next thing I want to do is the pagination where I use this:
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("[SIZE=3][B]SELECT ip, COUNT(*) as num FROM simplecount GROUP BY ip[/B][/SIZE]"),0);
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
// Build Page Number Hyperlinks
// Build Previous Link
if($pages > 1)
{
$prev = ($pages - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?stats=per_ips&pages=$prev\"><b>«</b></a> ";
}
for($i = 1; $i <= $total_pages; $i++)
{
if(($pages) == $i)
{
echo "$i ";
}
else
{
echo "<a href=\"".$_SERVER['PHP_SELF']."?stats=per_ips&pages=$i\">$i</a> ";
}
}
// Build Next Link
if($pages < $total_pages)
{
$next = ($pages + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?stats=per_ips&pages=$next\"><b>»</b></a>";
}
It's the SQL-query in the last code which is in bold I have problems with ... it outputs an IP-address starting with 129...* and since the rest of the code uses the 129 to figure out how many pages it needs - it gives me 7 pages whereas the output should have given me 11 ... Any ideas??