Tonny Feriandi Tonny Feriandi - 2 months ago 8x
Java Question

how to disable "WHERE" condition on php

I have

clause in my PHP. I need that condition, but sometimes I don't need it, here's my code:

(SELECT * FROM jasa WHERE kota = '$kota' order by id desc LIMIT :hal,7)

I need to know how to disable that clause. Sometimes I need a special condition from my data but sometimes I need to take all the data, or is there any command to take all data with

My best solution is use if command on my android apps, but it will take a long time and code.


Take the "where condition" out from the query and make the condition separately and add with the query .

if(condition to use where condition)
    $where = "WHERE kota = '$kota'";
    $where = "";
$query = "SELECT * FROM jasa ".$where." order by id desc LIMIT :hal,7";