Jump to content

Mysql search not working


ryanfilard

Recommended Posts

The results still return empty even when I type in the exact field name.

 

$idea = $_REQUEST['s'];
mysql_select_db($database_Users, $Users);
$query_search = "SELECT * FROM users WHERE username AND fname AND lname AND tags LIKE '$idea'";
$search = mysql_query($query_search, $Users) or die(mysql_error());
$row_search = mysql_fetch_assoc($search);

Link to comment
https://forums.phpfreaks.com/topic/242598-mysql-search-not-working/
Share on other sites

username AND fname AND lname AND tags

 

^^^ The above is logically AND'ing the contents of each of those columns together, which most likely is a TRUE value (unless you have FALSE and/or NULL values), then trying to see if TRUE LIKE '$idea'

 

What exactly are you trying to accomplish?

So, you want to match rows where any portion of the username is like $idea or any portion of the fname is like $idea or any portion of the lname is like $idea or any portion of the tags is like $idea?

 

SELECT * FROM users WHERE username LIKE '%$idea%' OR fname LIKE '%$idea%' OR lname LIKE '%$idea%' OR tags LIKE '%$idea%'

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.