多选的处理方式->大伙看看通不通

浏览:670 发布日期:2013/05/18 分类:求助交流
    public function insert() {
        $data = I('post.');
        $shiqu = $data['city_shi'];
        $coun = count($shiqu);
        if ($this->DB->create($data)) {
            if ($coun == 0) {
                $this->error('请选择城市!');
            } elseif ($coun == 1) {
                $this->DB->city_shi = $shiqu[0];
                if (false !== $this->DB->add()) {
                    $this->success('提交成功!');
                } else {
                    $this->error('提交失败!');
                }
            } else {
                foreach ($shiqu as $k => $v) {
                    $this->DB->city_shi = $v;
                    $this->DB->add();
                }
            }
        } else {
            $this->error($this->DB->getError());
        }
    }
我这样处理,没有勾选提示用户 请选择城市
勾选一个,写入正常
勾选二个以上 就出现空白!

大侠路过还望指点一二

最佳答案
评论( 相关
后面还有条评论,点击查看>>