关于复选框的问题@! 请参考SMARTY的html_checkboxes部分,例子非常详细。链接 点击查看 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 具体的代码就不写了,实现的思路就是将从数据库中取出的相应的国家和复选框中的value值比较,如果相同就设置其属性为checked="checked"即可 or where PHP code is:<?php$smarty->assign('cust_checkboxes', array( 1000 => 'Joe Schmoe', 1001 => 'Jack Smith', 1002 => 'Jane Johnson', 1003 => 'Charlie Brown') );$smarty->assign('customer_id', 1001);?>and the template is{html_checkboxes name='id' options=$cust_checkboxes selected=$customer_id separator='<br />'}both examples will output:<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br /><label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label><br /><label><input type="checkbox" name="id[]" value="1002" />Jane Johnson</label><br /><label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br /> SICTXK 谢谢你 但是 你的这个只是输出。 。请问 如何和数据库的值做比较? $smarty->assign('customer_id', 1001);1001这个值就是在数据库中的取值。在进行assign之前是从数据库取值,设此值为$arr_check_customer,既可以为单个值1001也可以为数组。$smarty->assign('customer_id', $arr_check_customer);页面在输出时就可以将$arr_check_customer中的值显示为选中。 哪能搞到 spl 源码 请问下.PHP中的::代表什么啊? 正则表达式中出现若干空格和换行应该怎么配 请问CSDN在结贴时鼠标移到某个框就显示还有多少分的做法,如何实现? $conn这个到底有什么用? 关于phpED的问题? 新手求教php中多维数组的读取 标头不能发出 windows下同时支持asp和php4+mysql的办法? 我能够熟练的运行ASP,PHP,JSP,ISAPI进行WEB开发。 PHP读取xml数据 PHP+MYSQL 部分记录无法更新。求达人解惑。
<?php$smarty->assign('cust_checkboxes', array(
1000 => 'Joe Schmoe',
1001 => 'Jack Smith',
1002 => 'Jane Johnson',
1003 => 'Charlie Brown')
);
$smarty->assign('customer_id', 1001);?>and the template is{html_checkboxes name='id' options=$cust_checkboxes
selected=$customer_id separator='<br />'}both examples will output:<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br />
<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label>
<br />
<label><input type="checkbox" name="id[]" value="1002" />Jane Johnson</label><br />
<label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br />
在进行assign之前是从数据库取值,设此值为$arr_check_customer,既可以为单个值1001也可以为数组。
$smarty->assign('customer_id', $arr_check_customer);
页面在输出时就可以将$arr_check_customer中的值显示为选中。