Re: [SMARTY] ... just beginning

From: Date: Wed, 10 Apr 2002 18:12:30 +0000
Subject: Re: [SMARTY] ... just beginning
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3640@lists.php.net to get a copy of this message
On Thursday 11 April 2002 01:38 pm, you wrote: There are two ways to achive this, assign both arrays as described on page 49 of the manual: in your php script assign your arrays to smarty $smarty->assign('ids', $catid); $smarty->assign('cats', $category ); In your template: <select name="categories"> {html_options values=$ids output=$cats} </select> Alternatively, I prefer to use this format: $sql = "select catId, category from categories"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { $categories[$row['catId']] = $row["category"]; } $smarty->assign('cats', $categories); In your template <select name="categories"> {html_options options=$ids output=$cats} </select> If you need to assign the selected value, follow the example on page 49 of the docs (which I find to be quite useful). Good luck! Craig > i'm new at smarty, and even though the manual is 112 pages long, it's > terribly non-informative from a "how to" point of view.. so hopefully you > guys can help. > > I am retreiving results from mysql and using a while loop to assign the > values to an array. The following is the code: > > $sql = "select catId, category from categories"; > $result = mysql_query($sql); > while ($row = mysql_fetch_array($result)) { > $catId = $row["catId"]; > $category = $row["category"]; > > > } > > I am using these results in a select box in my html form. I assume I will > use HTML_OPTIONS to accomplish this. My question is, how do I assign > values that smarty will understand and therefore give me the desired > options list in my html form? > > thanks for ur help > blue

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