Tonny Feriandi Tonny Feriandi - 1 year ago 82
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.

Answer Source

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";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download