Php search filter showing all rows without filtering : <p>While displaying the filtered data, this sql can filter data as per $locationone and $locationtwo.</p>

<p>But it is failing to filter data as per <strong>$cate</strong></p>

<p>I mean its displaying all the rows from both locations and failing to filter it as per <strong>science(topic)</strong></p>

<pre><code>$cat= "science";
$cate= preg_replace("#[^0-9a-z]#i","", $cat);
$locationone= "dhk";
$locationtwo= "ctg";
preg_replace("#[^0-9a-z]#i","", $locationone);
preg_replace("#[^0-9a-z]#i","", $locationtwo);
$sql= "SELECT * FROM post INNER JOIN user ON post.user_id= user.id
WHERE post.topic LIKE '%$cate%'
AND post.location LIKE '%$locationone%' 
OR post.location LIKE '%$locationtwo%'
order by post_id desc";
</code></pre>
