How to filter select input using like clause in php

Viewed 73

I am trying to filter the content based on location and category where category is fetched from dropdown but when filtering on basis of category it doesn't show the data row in which the particular option of dropdown is present Here is my code

if(isset($_POST['filter']))
{
$location = $_POST['location']; //input type = text
$category = $_POST['category']; //select type
$query = "
SELECT * FROM detail
WHERE  `c_JobCategory` LIKE '%".$category."%'
OR  `c_City` LIKE '%".$location."%'
OR `c_Country` LIKE '%".$location."%'

";
$search_result = filterData($query);
}

it is working when filtering on basis of location but not on category based

1 Answers
$query = "
SELECT * FROM `detail`
WHERE  `c_JobCategory` LIKE '%$category%'
OR  (`c_City` LIKE '%$location%'
OR `c_Country` LIKE '%$location%')";

i hope it'll help

Related