Lenton Posted February 10, 2010 Share Posted February 10, 2010 I currently use this MYSQL query in PHP: mysql_query("SELECT * FROM test WHERE input = '$input'"); The problem with this is that you have to enter the exact input. For example if the input was 'red socks' if the user typed in 'socks red' it wouldn't find it. I've explored various options like explode and wildcard but can't get any of them to work. Hope you can help me. Link to comment https://forums.phpfreaks.com/topic/191676-mysql-database-search/ Share on other sites More sharing options...
sader Posted February 10, 2010 Share Posted February 10, 2010 mysql_query("SELECT * FROM test WHERE input = LIKE '%$input%'"); Link to comment https://forums.phpfreaks.com/topic/191676-mysql-database-search/#findComment-1010345 Share on other sites More sharing options...
Orionsbelter Posted February 10, 2010 Share Posted February 10, 2010 You need to learn about wildcards Link to comment https://forums.phpfreaks.com/topic/191676-mysql-database-search/#findComment-1010346 Share on other sites More sharing options...
Lenton Posted February 10, 2010 Author Share Posted February 10, 2010 mysql_query("SELECT * FROM test WHERE input = LIKE '%$input%'"); Wouldn't that simply accept the string with anything before or after? Link to comment https://forums.phpfreaks.com/topic/191676-mysql-database-search/#findComment-1010398 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.