I want to query data in mysql like:
$cid=$_POST["cid"];
$room_id=$_POST["room_id"];
$time=$_POST["time"];
$reuslt=$this->db-query("SELECT * FROM mytable WHERE if($cid is not null){then check cid=$cid} else{don't check} AND if($room_id is not null){then check room_id=$room_id} else{don't check} AND if($time is not null){then check time=$time} else{don't check}");
How could I writ the correct sql to query data?
Aucun commentaire:
Enregistrer un commentaire