RE: [SMARTY] a little html_options problem
| From: | Obe, Regina DND\\MIS | Date: | Tue, 22 Mar 2005 14:42:20 +0000 |
| Subject: | RE: [SMARTY] a little html_options problem | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-12354@lists.php.net to get a copy of this message | ||
If you are using ADODB library to populate which it looks like you might be.
I think it might be easier to do something like
$query_category = "SELECT category_id, name FROM categories";
$resultcats = $conn->Execute($query_category);
$category_options = $resultcats->GetAssoc();
$smarty->assign("category_options",$category_options);
------TEMPLATE ---
{html_options options=$category_options selected="somevalue"}
-----Original Message-----
From: Willy Mularto [mailto:sangprabv@gmail.com]
Sent: Tuesday, March 22, 2005 7:47 AM
To: Smarty-General
Subject: [SMARTY] a little html_options problem
Hi,
I have a little problem about html_options, below is the code I use: php
side: <?php .. $query_category = "SELECT * FROM categories"; $resultcats =
$conn->Execute($query_category);
while(!$resultcats->EOF)
{
$category_id[] = $resultcats->fields[category_id];
$category_name[] = $resultcats->fields[name];
$resultcats->MoveNext();
}
$smarty->assign("category_name",$category_name);
$smarty->assign("category_id",$category_id);
..
?>
template side:
{html_options values=$category_id output=$category_name}
result side:
<option value="0">Select Category ID</option>
<option label="main cateogory #1" value="1">main cateogory
#1</option><--
watch this
<option label="main cateogory #2" value="1">main cateogory
#2</option>
<--watch this
<option label="'Ini tes' yang "ini" juga"
value="2">test</option>
<option label="sub main category#1" value="3">test</option>
<option
label="sub test" value="4">sub test</option> <option
label=""
value="5"></option><-- watch this
As you see something wierd happened here, see the first, second and last
options. the first and the last return the same value "1" and the last is
empty "". If I try just to echo it, everything is fine. But when I implement
the html_options it happened. What missed here? Thankyou for any reply..
Regards
Willy
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php