请参考SMARTY的html_checkboxes部分,例子非常详细。
链接 点击查看

解决方案 »

  1.   

    具体的代码就不写了,实现的思路就是将从数据库中取出的相应的国家和复选框中的value值比较,如果相同就设置其属性为checked="checked"即可
      

  2.   

     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 />
      

  3.   

     SICTXK  谢谢你 但是 你的这个只是输出。 。请问 如何和数据库的值做比较?
      

  4.   

    $smarty->assign('customer_id', 1001);1001这个值就是在数据库中的取值。
    在进行assign之前是从数据库取值,设此值为$arr_check_customer,既可以为单个值1001也可以为数组。
    $smarty->assign('customer_id', $arr_check_customer);
    页面在输出时就可以将$arr_check_customer中的值显示为选中。