Experts Round Table Network
Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:
Password:
Remember me
Forgot your password?
Register
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
Home
Help
Search
Login
Register
Experts Round Table Network
|
Serverside Technology
|
PHP
|
Pagination and Mod_rewrite
« previous
next »
Pages:
[
1
]
Print
Author
Topic: Pagination and Mod_rewrite (Read 240 times)
seandelaney
Mentor
Offline
Posts: 119
Pagination and Mod_rewrite
«
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
Sean
Mentor Written Articles:
http://www.expertsrt.com/articles/index.shtml
VGR
Mentor
Offline
Posts: 682
Re: Pagination and Mod_rewrite
«
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
Posts: 119
Re: Pagination and Mod_rewrite
«
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
Sean
Mentor Written Articles:
http://www.expertsrt.com/articles/index.shtml
VGR
Mentor
Offline
Posts: 682
Re: Pagination and Mod_rewrite
«
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
Posts: 682
Re: Pagination and Mod_rewrite
«
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
Posts: 119
Re: Pagination and Mod_rewrite
«
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
Sean
Mentor Written Articles:
http://www.expertsrt.com/articles/index.shtml
VGR
Mentor
Offline
Posts: 682
Re: Pagination and Mod_rewrite
«
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
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
ERT 1.5
-----------------------------
=> Round Table Learning Center
=> Bug reports
-----------------------------
Legacy
-----------------------------
=> The next level
=> History of ERT
-----------------------------
Community Affairs
-----------------------------
=> Introductions
=> Ballot Box
===> Closed Polls
=> Soapbox
=> Propose and Consult
===> Propose and Consult...CLOSED
-----------------------------
Bits and Bytes
-----------------------------
=> Tips, Tricks, Snippets, Tidbits And General Pearls Of Wisdom
-----------------------------
Serverside Technology
-----------------------------
=> PHP
=> ASP
-----------------------------
Webservers
-----------------------------
=> Apache
=> IIS
-----------------------------
Databases
-----------------------------
=> MySQL
=> Access
=> MS SQL Server
-----------------------------
Clientside Technology
-----------------------------
=> HTML
=> CSS
=> Javascript
=> Flash
=> WAP/WML
-----------------------------
Web Technologies
-----------------------------
=> General Web Dev
=> Web Standards
=> XML
=> Online Marketing
-----------------------------
Graphics
-----------------------------
=> Graphics Design and Animation
-----------------------------
Programming
-----------------------------
=> .NET
=> JAVA
=> MS DOS Batch Scripting
=> Mathematics
=> C & C++
=> VB
=> Delphi
=> Algorithm design
-----------------------------
Operating Systems
-----------------------------
=> Windows (General)
=> NT Based (2K, 2K-03, NT, XP, Vista)
=> Open Source (All)
-----------------------------
Hardware
-----------------------------
=> Hardware General
=> Gamers Hardware (Advanced)
-----------------------------
Networking
-----------------------------
=> Home (small)
=> Office (large)
=> Internet
-----------------------------
Security
-----------------------------
=> General Security Issues
-----------------------------
Rants/Opinions/Proposals
-----------------------------
=> Site operation
Powered by SMF 1.1 RC2
|
SMF © 2001-2005, Lewis Media
Joomla Bridge by
JoomlaHacks.com