You have a url like so:
http://www.domain.com/some_page.php?p=1
Now, to get the "page" variable, we call it like so in our PHP code:
<?php
$page = $_GET['p'];
// Prior to PHP 4.1.0 use the following:
// $page = $HTTP_GET_VARS['p']
echo $page;
?>
Using the URL above, that will give us an output of:
To get the total number of rows that mySQL returns, use the simple [man]mysql_num_rows/man function.
<?php
$q = "SELECT * FROM `table`";
$r = mysql_query($q);
$tr = mysql_num_rows($r);
echo "Total Rows is: ".$tr;
?>
Easy enough right? Then you can figure the rest out I think. You've got a good plan down, follow it and you should be golden.
If you want a little more advice, I would say this:
-- Run a query selecting all rows
-- Grab the number of total rows returned
-- loop through incrementing a value (like $i++)
-- IF($i >= $p && $i<($p+10)) show rows
-- Divide by 10 to get total pages
-- Display Pagination
So here is some mock-code:
<?php
$conn = mysql_connect('localhost', 'username', 'password');
mysql_select_db('database', $conn);
$query = "SELECT * FROM `table` ORDER BY id DESC";
// Puts the most recent at the top by id, if you have a date field, use that instead
$result = mysql_query($query);
$rows = mysql_num_rows($result);
$pages = $rows/10;
$curpage = $_GET['p'];
$i = 1;
while($row = mysql_fetch_array($result))
{
if($i>=$curpage && $i<($curpage+10))
{
echo $row.'<br>';
}
$i++; // keeps track of what row you're on so that you only show the relevant
// results.
}
?>
Hope that helps you!!
~Brett