Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:

Password:

Remember me

Pagination and Mod_rewrite
Welcome, Guest. Please login or register.
December 04, 2008, 12:07:55 AM
11306 Posts in 1249 Topics by 499 Members
Latest Member: haulaslemycle
Experts Round Table Network  |  Serverside Technology  |  PHP  |  Pagination and Mod_rewrite « previous next »
Pages: [1]
Author Topic: Pagination and Mod_rewrite  (Read 240 times)
seandelaney
Mentor

Offline Offline

Posts: 119



WWW
« on: January 29, 2007, 08:07:05 AM »

im using pagination for a set of query results.

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

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

.htaccess file:

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

results.php file:

Code:
$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();
   
foreach($pagedata as $row)
{
       // more code here
       $s_HtmlContent .= '<p>'.$row['description'].'</p>'."\n";
       // more code here
}

$s_HtmlContent .= '<p>Page: '.$links['all'].'</p>'."\n";

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.html.pager.intro.php
« Last Edit: January 29, 2007, 09:37:39 AM by seandelaney » Logged

VGR
Mentor

Offline Offline

Posts: 682



WWW
« Reply #1 on: January 29, 2007, 11:14:28 AM »

personally, if I were you, I would save thousands of milliseconds not queryinf for "*" but for the limited subset corresponding to the page n

example if a page has 100 rows displayed :
select * from trucmuche ORDER BY... LIMIT 100*(n-1),100;

got it ? you will only query 100 rows, the exact contenance of your page.

I didn't read the rest, but this "jumped to my eyes" (translatation not guaranteed)
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
seandelaney
Mentor

Offline Offline

Posts: 119



WWW
« Reply #2 on: January 29, 2007, 11:42:22 AM »

Sorry VGR, the "SELECT * FROM" was just for example.

however even for a simple query my pagination does not work if i try jumping to page 2 for example..
Logged

VGR
Mentor

Offline Offline

Posts: 682



WWW
« Reply #3 on: January 29, 2007, 11:59:07 AM »

ok, so the not initialized counter and array $data are also for demo purposes, right ?

then sorry but I solved the problem myself in pure normal PHP for eee.org (and it works! Yes ma'm ;-), while you use a class that I don't know anything about.

personally, if by following the examples furnished with the class, I didn't suceed at least in a so basic task, I would drop the class and try an other one. And in last resort, having seen hundreds of lines of code that don't work as expected, I would rewrite/do it myself ;-)
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
VGR
Mentor

Offline Offline

Posts: 682



WWW
« Reply #4 on: January 29, 2007, 12:02:12 PM »

side note : I never liked pear stuff. too much OO in there. black boxes. do it yourself or it's valueless.
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
seandelaney
Mentor

Offline Offline

Posts: 119



WWW
« Reply #5 on: January 29, 2007, 12:07:46 PM »

Quote
ok, so the not initialized counter and array $data are also for demo purposes, right ?

not actually, just the SELECT query - i can modify my first comment with the real query if you want...?  The rest of the code is not example.

also eee.org redirects to http://www.uia.net/

« Last Edit: January 29, 2007, 12:13:14 PM by seandelaney » Logged

VGR
Mentor

Offline Offline

Posts: 682



WWW
« Reply #6 on: January 29, 2007, 02:31:32 PM »

yeah, some evil people took that acronym as a domain name ;-)

look my signature to know what is "the" eee.org
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
Pages: [1]
« previous next »
    Jump to: