Pagination with mod_rewrite

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!

Moderator: General Moderators

Post Reply
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Pagination with mod_rewrite

Post by amir »

Hello,

I am using pagination for a set of query results.

the website now uses friendly URL's with the help from mod_rewrite.

I am trying to get my pagination working again but in having trouble...

.htaccess file:

Code: Select all

RewriteRule ^/results/page([0-9]{1,4})(/)$ results.php?num=$1 [L]
results.php file:

Code: Select all

$query = "SELECT * FROM tblJobs";
$result = mysql_query($query) or die(mysql_error());
     
while($row = mysql_fetch_array($result))
{
     $data[] = $row;
     $i_Total++;
}
     
$params = array(
     'itemData' => $data,
     'perPage' => 5,
     'append' => false,
     'urlVar' => 'num',
     'mode' => 'Jumping',
     'path' => 'http://quest-recruiting/results/',
       'fileName' => 'page%d/'
);
     
$pager = & Pager::factory($params);
$pagedata = $pager->getPageData();
$links = $pager->getLinks();
     
if($pager->isLastPage())
{
     $items = $pager->numItems() % $params['perPage'];
}
else
{
     $items = $params['perPage'];
}
     
list($first, $last) = $pager->getOffsetByPageId();
     
$s_HtmlContent .= '<p>Page: '.$links['all'].'</p>'."\n";
$s_HtmlContent .= '<p>Results '.$first.' - '.$last.' of about '.$pager->numItems().'</p>'."\n";

foreach($pagedata as $row)
{
       // more code here
       $s_HtmlContent .= '<p>'.$row['description'].'</p>'."\n";
       // more code here
}
the example i was trying to follow to integrate my code with mod_rewrite was from this tutorial:

http://pear.php.net/manual/en/package.h ... .intro.php

TIA!
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

I am trying to get my pagination working again but in having trouble.
That's awful. I hope you manage to fix it.

For future reference, telling people what the problem is might help.
Post Reply