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. Sorry for my bad english. Thank you, Geo -- George Alexandru Dudău CORE IT MEX - Grupul de firme MOBEXPERT Network administrator | proiecte web | proiecte speciale Tel : +40 21 2421040-1139 http://www.itmex.ro _______________________________________________ MediaWiki-l mailing list [hidden email] https://lists.wikimedia.org/mailman/listinfo/mediawiki-l |
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 _______________________________________________ MediaWiki-l mailing list [hidden email] https://lists.wikimedia.org/mailman/listinfo/mediawiki-l |
In reply to this post by George Alexandru Dudău
> From: George Alexandru Dud?u <[hidden email]>
> > How can i make pagination from database query in mediawiki? I want to > show just 25 items on a page. I just posted a hack to SQL2Wiki that does this: http://www.mediawiki.org/wiki/Extension:SQL2Wiki My changed version is on the talk page: http://www.mediawiki.org/wiki/Extension_talk:SQL2Wiki#Enhancements WARNING: only use this extension if you trust your user base. It should NOT be installed an a system where anyone can create an account that is capable of editing pages! :::: The white man seeks to conquer nature, to bend it to his will and to use it wastefully until it’s all gone and then he simply moves on, leaving the waste behind him and looking for new places to take. The whole white race is a monster who is always hungry and what he eats is land. — Chiksika, elder brother of Tecumseh, March 19, 1779 :::: Jan Steinman, http://www.Bytesmiths.com _______________________________________________ MediaWiki-l mailing list [hidden email] https://lists.wikimedia.org/mailman/listinfo/mediawiki-l |
Free forum by Nabble | Edit this page |