Re: Advanced Example for Smarty, Sections, MySQL ?

From: Date: Sun, 04 Feb 2001 20:40:43 +0000
Subject: Re: Advanced Example for Smarty, Sections, MySQL ?
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-60@lists.php.net to get a copy of this message
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}

« previous php.smarty.general (#60) next »