For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > January 2005 > Re: [SMARTY] Paging Records Help please









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] Paging Records Help please
Andre Gemünd

2005-01-09, 3:58 pm

Jim MacDiarmid wrote:
> I'm new to Smarty and I'm having some serious trouble getting adjusted to
> how things work. I'm using the PEAR::DB object to pull data from my
> database. I'd like to be able to show a paged list of the data. Will I need
> to use 2 queries if I want to have a page index? One query for the page
> index and one for the list? I'm attempting to use PEAR's DB_Pager.


Hi Jim,
its generally a good idea to read the crashcourse
http://smarty.php.net/crashcourse.php before writing applications.
After that its more of a pear thing your asking about.
In my opinion DB_Pager isn't efficient, use PEAR::Pager instead. After
installing with pear install Pager there will be a Pager folder inside
your PEARs doc-folder. Look at the example Pager_Wrapper, there is a
function called Pager_Wrapper_DB() which returns an array. You just have
to assign this array to your template instance with e.g.
$smarty->assign('pageData', Pager_Wrapper_DB($db, $sql, $pagerParams));
In your template you can loop with $pageData.data.
For further information please use the great smarty and pear
documentation at http://smarty.php.net/ and http://pear.php.net/.

hth
André

ps: please write a new message instead of answering one, if you change
the topic.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com