-3

I am beginner in php. I am using core PHP. I want to make onkeyup filter in input box.I used some ajax for display the data in same page and i am trying these php code.

$text = $_POST['text'];

$result = mysqli_query($conn,"select * from project where name LIKE '%$text%' or type LIKE '%$text%' or sector LIKE '%$text%' or city LIKE '%$text%' or builder LIKE '%$text%' && status='1' LIMIT 6");

My filter is working but not comparing with status status=1. status=0 is deleted item and status=1 is active item. But in my filter box status=0 is also showing.

Please solve the problem. Your answer is highly appreciated. Thanks

EDIT: I tried both &&, AND operator. Still not working

Inderjeet
  • 1,488
  • 2
  • 17
  • 30

1 Answers1

4

You have problem with syntax of mysql. Use (``) in the field of tables.

You should use parenthesis wit () to group between OR and AND. This may help.

$result = mysqli_query($conn,"select * from project where ((`name` LIKE '%$text%') OR (`type` LIKE '%$text%') OR (`sector` LIKE '%$text%') OR (`city` LIKE '%$text%') OR (`builder` LIKE '%$text%')) AND `status`='1' LIMIT 6");
Virb
  • 1,639
  • 1
  • 16
  • 25