CI框架的一些笔记

1)根据View层进入时候从数据库中拿到的data来判断select是否显示,达到默认选中的目标

<select name="data[stat]">
                                <option value="0" <?php if(isset($data['stat']) && $data['stat'] == 0 && $data['stat'] != '') : echo 'selected="selected"'; endif;?>>下线</option>
                                <option value="1" <?php if(isset($data['stat']) && $data['stat'] == 1 && $data['stat'] != '') : echo 'selected="selected"'; endif;?>>正常</option>
                                <option value="2" <?php if(isset($data['stat']) && $data['stat'] == 2 && $data['stat'] != '') : echo 'selected="selected"'; endif;?>>删除</option>
                            </select>

2)数据库条件筛选

$haveItemKey = $this->artisan_item_list->findAll(array('item_key'=>'meifa_xczx','artisan_id ='=> $data['artisan_id'],'id !='=> $data['id']));
可以在数组里面以这种形式来筛选
'id !='=> $data['id']

3)传递一些隐藏的值,form表单提交

<input type="text" style="display: none;" name="data[artisan_id]" id="artisan_id" class="input-xlarge" value="<?php echo $data['artisan_id'];?>">

4)控制器看form表单传过来的值

$post = $this->input->post();
var_dump($post);

5)多个<?php ?>的嵌套是可以这样用的

<?php if($skill[6] == $data['skill']): ?>
            <a href="<?php echo create_url('salon/artisan_shop', array('artisan_id' => $data['artisan_id'])); ?>" style="margin-left:5px"><button class="btn btn-primary">选择</button></a>
            <?php endif; ?>


你可能感兴趣的:(PHP)