<?php
/**
* This is a bogus example of how to count the total number of pages
* in a database table, where each page consists of a certain number
* of rows, or part thereof.
* We shall connect to and select the mysql database to start
**/
$rows_per_page = 10; //you might change this to 7
$db = mysql_connect("localhost", "username", "password")
OR die("Error: cannot connect to database!");
mysql_select_db("database_name", $db)
OR die("Error: cannot select database!");
//assume there is an 'id' index in table 'tablename'
$query = mysql_query("SELECT id FROM tablename");
$total = mysql_num_rows($query);
$pages = ceil($total / $rows_per_page);
//wow, now $pages contains the total number of pages!
//release the member associated with the query
mysql_free_result($query);
//then disconnect, since you apparently wish to do so explicitly
mysql_close($db);
?>
Well, why use ceil()?
Consider
n: number of rows
p: number of pages
For the case of 5 pages per row,
n=0 => p = ceil(0/5) = 0
n=1 => p = ceil(1/5) = 1
n=2 => p = ceil(2/5) = 1
n=3 => p = ceil(3/5) = 1
n=4 => p = ceil(4/5) = 1
n=5 => p = ceil(5/5) = 1
n=6 => p = ceil(6/5) = 2
n=7 => p = ceil(7/5) = 2
n=8 => p = ceil(8/5) = 2
n=9 => p = ceil(9/5) = 2
n=10 => p = ceil(10/5) = 2
n=11 => p = ceil(11/5) = 3
isnt that the required result?