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.