View Single Post
  #2  
Old 08-28-2006, 01:57 PM
hannah hannah is offline
OSP Addicts
 
Join Date: Apr 2006
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
hannah is on a distinguished road
Default

HI,

This is the simple code that you can use for paging.
include this code on your page.


Code:
function getPageNum($tblName, $scriptName)
{
$pageNum = 0;
$pageCnt = 0;
$recNum = 10;

$query = "SELECT * FROM $tblName";
$result=mysql_query($query);
$rownum=mysql_num_rows($result);


if($rownum > 0)
{
$pageNum = ceil($rownum/$recNum);

for($i=0; $i<$pageNum; $i++)
{
$pageCnt = $i * $recNum;

if(isset($_REQUEST['pageNo']) AND $_REQUEST['pageNo']== ($i+1))
{
echo "<b>".($i+1)."</b>**";
}
else
{
echo "<a href='$scriptName?recNum=$recNum&startNum=$pageCnt &pageNo=".($i+1)."'> -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
  Webmaster Forums - View Single Post - how to do paging
View Single Post
  #2  
Old 08-28-2006, 01:57 PM
hannah hannah is offline
OSP Addicts
 
Join Date: Apr 2006
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
hannah is on a distinguished road
Default

HI,

This is the simple code that you can use for paging.
include this code on your page.


Code:
function getPageNum($tblName, $scriptName)
{
$pageNum = 0;
$pageCnt = 0;
$recNum = 10;

$query = "SELECT * FROM $tblName";
$result=mysql_query($query);
$rownum=mysql_num_rows($result);


if($rownum > 0)
{
$pageNum = ceil($rownum/$recNum);

for($i=0; $i<$pageNum; $i++)
{
$pageCnt = $i * $recNum;

if(isset($_REQUEST['pageNo']) AND $_REQUEST['pageNo']== ($i+1))
{
echo "<b>".($i+1)."</b>**";
}
else
{
echo "<a href='$scriptName?recNum=$recNum&startNum=$pageCnt &pageNo=".($i+1)."'> -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote