RE: [SMARTY] ... just beginning
| From: | LIMBOURG Arnaud | Date: | Thu, 11 Apr 2002 18:04:09 +0000 |
| Subject: | RE: [SMARTY] ... just beginning | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-3639@lists.php.net to get a copy of this message | ||
> 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.
True, it's good from a reference point of view, but otherwise quite
complicated when beginning.
> 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?
you will want to use either a section or a foreach construct.
something like
select
{section name=mysec loop=$HTML_OPTIONS}
option {$HTML_OPTIONS[mysec]} /option
{/section}
or
{foreach key=key item=item loop=$HTML_OPTIONS}
option value=$key $item /option
{/foreach}
/select
The synta of the foreach maybe buggy, i just wrote it out of my head. but
it's in the doc ;))
> thanks for ur help
> blue
>