Re: [SMARTY] ... just beginning

From: Date: Thu, 11 Apr 2002 18:23:20 +0000
Subject: Re: [SMARTY] ... just beginning
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3642@lists.php.net to get a copy of this message
Craig wrote:
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>
I don't think you want the output attribute, that is all gotten from the options array.
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
-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.

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