Re: Advanced Example for Smarty, Sections, MySQL ?
| From: | taliku at balcab dot ch | Date: | Sun, 04 Feb 2001 21:20:58 +0000 |
| Subject: | Re: Advanced Example for Smarty, Sections, MySQL ? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-61@lists.php.net to get a copy of this message | ||
Thank you very much!
It worked!
taliku
----- Original Message -----
From: "Joris Trooster" <trooster@interstroom.nl>
To: <taliku@balcab.ch>; <Smarty@lists.ispi.net>
Sent: Sunday, February 04, 2001 9:40 PM
Subject: [smarty] Re: Advanced Example for Smarty, Sections, MySQL ?
> There are many ways to do this. It depends on how you would have control
> over the database output, etc.
> Here is one example:
>
> template.php :
>
> $template = new Smarty;
> $scores = mysql_pconnect("www.zend.com", "sports","scores");
> $db = mysql_select_db("sports");
> $query = "select * from soccer_scores"; // db fields: team, goals
> $result = @mysql_query($query);
> $scores = array();
> while ($row = mysql_fetch_array($result)) array_push($scores, $row);
> $template->assign("scores", $scores);
> $template->display("template.tpl");
>
>
> template.tpl :
>
> {section name=soccer loop=$scores}
> {$soccer/scores.team}- {$soccer/scores.goals}<br>
> {/section}
>
>
> ---
> You are currently subscribed to smarty as: taliku@balcab.ch
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at Ù¹è±7j
> •±L‘ØúÎŽhttp://www.phpinsider.com/php/code/Smarty/