Re: [SMARTY] Take a look at this problem
| From: | Vladimir Kravtsov | Date: | Fri, 03 Jan 2003 20:20:10 +0000 |
| Subject: | Re: [SMARTY] Take a look at this problem | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7003@lists.php.net to get a copy of this message | ||
this was what i was looking for. many thanks
----- Original Message -----
From: "M Mohr" <messju@lammfellpuschen.de>
To: "Vladimir Kravtsov" <vkravtsov@rogers.com>
Cc: <smarty-general@lists.php.net>
Sent: Friday, January 03, 2003 1:19 AM
Subject: Re: [SMARTY] Take a look at this problem
> hello,
>
> On Thu, Jan 02, 2003 at 07:34:06PM -0800, Vladimir Kravtsov wrote:
> > I have the following code:
> >
> > <?php
> > require ('common.php'); //Includes all of the pre-written functions
> > connectdb(); //Connects to the database
> > //This is the Smarty template system
> > define('SMARTY_DIR','c:/inetpub/wwwroot/newphp/x-news/');
> > require(SMARTY_DIR.'Smarty.class.php');
> > $smarty = new Smarty;
> > $smarty->template_dir = "c:/inetpub/wwwroot/newphp/x-news/templates/";
> > $smarty->compile_dir = "c:/inetpub/wwwroot/newphp/x-news/templates_c/";
> >
> >
> > $query = mysql_query("SELECT postid, subject, body, authoremail,
authorname, date, time FROM posts ORDER BY postid ASC");
> > while ($row = mysql_fetch_array($query)) {//Selects all of the posts
> > //Assign the information to the template
> > $smarty->assign('newsbox',
> > Array('postid'=>$row['postid'], 'subject' =>
> > $row['subject'], 'body'
=>$row['body'], 'authoremail'
=>$row['authoremail'],'date' =>$row['date'],
'time' =>$row['time'], 'authorname' =>
$row['authorname'] ));
> >
>
> how does the template look like?
> it looks to me you want to do $smarty->append('newsbox', ...) instead
> of assign, instead of assign. assign overwrites the old value of newsbox.
>
> in your template you can loop over your newsbox array with foreach.
>
> HTH
> messju
>
> > }
> > $smarty->display('index.tpl');
> > //Shows the page
> >
> >
> >
> >
> >
> >
> >
> > ?>
> >
> > This only prints the first entry in my databse (my template just prints
things like newsbox.postid.
> > How can I make this print all of the entries?
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>