Paging Question
Posted: Sun Jun 28, 2009 2:31 am
I can't figure out where I'm going wrong. I am trying to setup paging to show 5 rows per page. But it's not working out correctly. Any thoughts on why?
Code: Select all
include("dbinfo.inc.php");
include("header.inc");
//how many rows to show per page
$rowsPerPage = 5;
//show first page by default
$pageNum = 1;
// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
// counting the offset
$offset = ($pageNum - 1 * $rowsPerPage);
mysql_connect("$hostname",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query= "SELECT * FROM scores order by ID DESC";
"LIMIT $offset, $rowsPerPage";
$result=mysql_query($query);
//print the pages
while($row = mysql_fetch_array($result))
{
echo $row['user'] . ' bowled a' . $row['score'] . ' on ' . $row['date'] . '<br>';
}