Re: [SMARTY] PEAR::DB and Smarty
| From: | Eskil Kvalnes | Date: | Sat, 03 Aug 2002 08:10:33 +0000 |
| Subject: | Re: [SMARTY] PEAR::DB and Smarty | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5570@lists.php.net to get a copy of this message | ||
Thanks! That last bit did the trick! :-)
Somewhat easier than my way too. (Wich worked when I was using PEAR::IT).
Anyway, thanks again :)
---------------
Sincerely,
Eskil Kvalnes
eskil@uten.net
----- Original Message -----
From: "Hendy Irawan" <ceefour@gauldong.net>
To: <smarty-general@lists.php.net>
Sent: Saturday, August 03, 2002 9:57 AM
Subject: Re: [SMARTY] PEAR::DB and Smarty
> smarty-general,
>
> > <code>
> > while ($newsRow = $newsResult->fetchRow(DB_FETCHMODE_ASSOC)) {
> > $_SMARTY->assign("NEWSID", $newsRow['newsId']);
> > $_SMARTY->assign("NEWSTOPIC", $newsRow['newsTopic']);
> > $_SMARTY->assign("NEWSDATE", $newsRow['newsTopic']);
> > $_SMARTY->assign("NEWSSYNOPSIS",
enable_url($newsRow['newsSynopsis']));
> > }
> > </code>
>
> > and this is how I try to loop the results in index.tpl.htm:
>
> > <code>
> > {section name=news loop=$newsRow}
>
> Simple!! You haven't done something like this:
>
> $_SMARTY->assign("newsRow", $newsRow /* or whatever */);
>
> Anyways, your way of doing this up there is somehow rather not so
> proper... (tell me if I'm wrong!!!)
>
> What you've got to do is load ALL the data into ONE array. Then do the
> {section} on it. Refer to {section} or {foreach} documentation on how
> to do so.
>
> BTW I usually do something like this: (this is using mysql API, but I
> think you know how to do it using PEAR)
>
> data = array();
> while ($row = mysql_fetch_assoc($result)) $data[] = $row;
> $smarty->assign('data', $data);
>
> then do a {foreach} :
>
> {foreach from=$data item=row}
> Name: {$row.name}<br />
> Address: {$row.address}<br />
> {/foreach}
>
> (please anybody else tell me if the above code is wrong because I
> didn't have time to check it out)
>
> Salam hangat,
> Hendy Irawan - www.GaulDong.NET
> Kantor: (021) 5260467 [SoftVation]
> Kos: (021) 5261839 [kamar 3]
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>