George Alexandru Dudău wrote:
Hi everybody,
How can i make pagination from database query in mediawiki? I want to
show just 25 items on a page.
I make an extension who query database and show in a page the result,
but are too many (2000 items).
My code is:
"$dbr =& wfGetDB( DB_SLAVE );
$res = $dbr->select( 'tabel',
array('id','row1','row2') );
$wgOut->addHTML ("<table>");
$wgOut->addHTML
("<tr><th>ID</th><th>ROW1e</th><th>ROW2</th></tr>");
while ( $row = $dbr->fetchObject( $res ) ) {
$wgOut->addHTML ("<tr><td>" .
$row->id . "</td><td>" .
$row->row1 . "</td><td>" .
$row->row2 . "</td>");
}
The result is:
ID ROW1 ROW2
1 row1 row2
2 row1 row2
3 row1 row2
...
1000 row1 row2
1001 row1 row2
Please, if you know or you have a link from where i must learn this,
tell me.
Use the TablePager class. It is very cool. I may be biased since I did
write it, but it is one of my favourites. The documentation is in the
source.
-- Tim Starling