1:ADODB 中GETALL 的问题 2:SMARTY中下拉框动态显示的问题

1、GETALL 方法期望返回一个数组,不成功时返回假
实用时宜
$queryc="select count(*) from table1";
if($result=$db->GetAll($query)){
//成功时的操作
}

2、见手册中的例子,当然选中项你要适当保存
index.php:

require('Smarty.class.php');
$smarty = new Smarty;
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
Johnson','Carlie Brown'));
$smarty->assign('customer_id', 1001); //设置默认选项
$smarty->display('index.tpl');

index.tpl:

1<select name="customer_id">   
2{html_options values=$cust_ids selected=$customer_id output=$cust_names}   
3</select>

index.php:

require('Smarty.class.php');
$smarty = new Smarty;
$smarty->assign('cust_options', array(
1001 => 'Joe Schmoe',
1002 => 'Jack Smith',
1003 => 'Jane Johnson',
1004 => 'Charlie Brown'));
$smarty->assign('customer_id', 1001);
$smarty->display('index.tpl');

index.tpl:

1<select name="customer_id">   
2{html_options options=$cust_options selected=$customer_id}   
3</select>

OUTPUT: (both examples)

1<select name="customer_id">
2<option value="1000">Joe Schmoe</option>
3<option selected="selected" value="1001">Jack Smith</option>
4<option value="1002">Jane Johnson</option>
5<option value="1003">Charlie Brown</option>
6</select>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus