I have a search query that works great, but I need it to only show results where visible = true
. That's what needs to be added to the query, I just don't know how to do it correctly. Here's the query.
$query = $mysqli->query("SELECT id,name,company,town FROM people WHERE name LIKE '%$mysearchString%' OR company LIKE '%$mysearchString%' OR town LIKE '%$mysearchString%' ORDER BY name DESC LIMIT 100");
The开发者_运维百科 $mysearchString var is just a sanitized $_GET['s']
.
SELECT id,name,company,town
FROM people WHERE
(name LIKE '%$mysearchString%'
OR company LIKE '%$mysearchString%'
OR town LIKE '%$mysearchString%')
AND visible = true
ORDER BY name DESC LIMIT 100
$query = $mysqli->query("SELECT id,name,company,town FROM people WHERE (name LIKE '%$mysearchString%' OR company LIKE '%$mysearchString%' OR town LIKE '%$mysearchString%') AND visible = true ORDER BY name DESC LIMIT 100");
精彩评论