PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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?
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>';
}
<?
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>';
}
?>
$query= "SELECT * FROM scores order by ID DESC"; // This semicolon should be a dot and there should be a space between DESC and LIMIT
"LIMIT $offset, $rowsPerPage";
Edit: This post was recovered from search engine cache.