AppleTattooGuy
AppleTattooGuy

Reputation: 1175

MySQL PHP query not working correctly

The following code doesn't seem to be working correctly, when I put just 1 thing in WHERE it works fine so maybe I cant do multiple items in here?

The code snippet is

$query_view_users = "SELECT id, type, name, username, email FROM admin_users WHERE id, type, name, username, email LIKE '$search'";

Thank you so much for your help. :-)

Upvotes: 0

Views: 90

Answers (2)

John Woo
John Woo

Reputation: 263803

it's a multi-condition WHERE clause. use OR or AND which ever satifies your needs.

SELECT ...
FROM ....
WHERE id   LIKE '$search' OR 
      type LIKE '$search' OR 
      name LIKE '$search' OR 
      username LIKE '$search' OR 
      email    LIKE '$search'

Upvotes: 5

Gabamnml
Gabamnml

Reputation: 156

your sql would have to be

$query_view_users = "SELECT * FROM admin_users WHERE id OR type OR name OR username OR email LIKE '$search'";

Upvotes: 0

Related Questions