tp3.2中修改页面下拉菜单和单选按钮默认选中数据库里的数据问题!

//下拉菜单:

<select name="ccate" lay-filter="aihao">
                <option value="">请选择</option>
            <?php foreach($category as $key=>$value){ ?>
                <option value="<?php echo $value['id']?>" <?php if($result['pcate'] == $value['id']):?> selected <?php endif;?>><?php echo $value['name']?></option>
            <?php }?>
        </select>

此处:ccate用于控制器里接值,category为控制器方法里查询分类表里的结果集,$value['id']为分类表里自增id,$value['name']为分类表里分类名字,$result['pcate']为商品表结果集,其中pcate为商品表中分类id.


//单选按钮

 <input type="radio" name="recommend" value="1" title="是" <if condition="$result['recommend'] eq 1" >checked</if>>
      <input type="radio" name="recommend" value="0" title="否" <if condition="$result['recommend'] eq 0" >checked</if>>

此处:recommend为商品表里是否上架字段,$result为查询的商品结果集.


猜你喜欢

转载自blog.csdn.net/tianjingang1/article/details/75545212
今日推荐