【TP5】关于get请求的模糊搜索

版权声明:咔咔 来自https://blog.csdn.net/fangkang7 https://blog.csdn.net/fangkang7/article/details/85317595

author:咔咔

wechat:fangkangfk

在之前我们使用了ajax请求的方式做了一次模糊搜索,下面是链接地址

https://blog.csdn.net/fangkang7/article/details/85233164

今天我们写一个get请求方式的模糊搜索

注意点:

前端点击搜索后,搜索条件依然需要在

前端显示条件是需要做是否存在判断

后台之需要查询数据返回给前端即可

点击查询会直接将参数带到地址后边请求服务器

样式:

 

后台代码:

/**
     * banner列表
     * @return array
     */
    public function index()
    {
        $param = $this->request->param();

        $where = [];

        if(!empty($param['vt_id'])){
            $where['vt_id'] = $param['vt_id'];
        }

        if(!empty($param['b_title'])){
            $where['b_title'] = ['like',"%".$param['b_title']."%"];
        }

        if(!empty($param['vt_id']) && !empty($param['b_targetType']) && !empty($paran['b_title'])){
            $where = '1 = 1';
        }

        // banner列表
        $bannerList = $this->bannerModel->bannerList($where);

        // 类型
        $videoTypeList = Db::name($this->videoTypeModel->tableName)->select();

        if(!empty($param)){
            $this->assign('param',$param);
        }

        $this->assign([
            'subject' => $videoTypeList,
            'bannerList' => $bannerList
        ]);

        return $this->fetch();
    }

猜你喜欢

转载自blog.csdn.net/fangkang7/article/details/85317595