doushajian2018 2019-07-06 07:22
浏览 142

如何搜索具有父子关系的表?

I have a table named 'service_cat'. I want to make a search form to search in this table. user will enter a city name and service. and I have to search the database accordingly. the problem is if the user types a parent service name it doesn't have any city.

I have tried multiple select queries, nested queries but found nothing. https://ibb.co/GR3SKt3 is my DB table screenshot

if(isset($_POST["city"]) AND isset($_POST["service"])){

        $this->load->library("form_validation");

        $this->form_validation->set_rules("city", "City", "trim");
        $this->form_validation->set_rules("service", "Service", "trim");

        if($this->form_validation->run()){

            $city = sanitize_string(make_string($this->input->post("city"), "l"));
            $service = sanitize_string(make_string($this->input->post("service"), "l"));

            $this->load->model("services_model");

            $services = $this->services_model->query("select * from service_cat where service_name = '$service' AND city='$city'");

        }else{
            http_response_code(400);
            $data["res"] = "Invalid Request.";
        }

    }

i want to display parent child list in search result.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 单纯型python实现编译报错
    • ¥15 c++2013读写oracle
    • ¥15 c++ gmssl sm2验签demo
    • ¥15 关于模的完全剩余系(关键词-数学方法)
    • ¥15 有没有人懂这个博图程序怎么写,还要跟SFB连接,真的不会,求帮助
    • ¥15 PVE8.2.7无法成功使用a5000的vGPU,什么原因
    • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
    • ¥15 安装quartus II18.1时弹出此error,怎么解决?
    • ¥15 keil官网下载psn序列号在哪
    • ¥15 想用adb命令做一个通话软件,播放录音