Bradley_James Posted August 17, 2011 Share Posted August 17, 2011 Hey Guys- I built a page where bands and musicians can submit their name, genre and website to a database that others can search. I'm trying to figure out how to get my PHP code to search both by genre and band name. Here's the line of code I'm referring to: $query = "select * from Information where genre like \"%$trimmed%\" order by genre"; I assumed that I could add "OR" after "genre" and then type "bandname" after that, resulting in "where genre OR bandname like \%$trimmed\" however, this doesn't work. Any help would be appreciated! -Brad Link to comment https://forums.phpfreaks.com/topic/245029-simple-search-help-needed/ Share on other sites More sharing options...
premiso Posted August 17, 2011 Share Posted August 17, 2011 Check out this tutorial: http://www.phpfreaks.com/tutorial/simple-sql-search See if that helps ya. Link to comment https://forums.phpfreaks.com/topic/245029-simple-search-help-needed/#findComment-1258570 Share on other sites More sharing options...
WebStyles Posted August 17, 2011 Share Posted August 17, 2011 try something like this: $query = "select * from Information where genre like '%$trimmed%' or bandname like '%$trimmed%' order by genre"; Link to comment https://forums.phpfreaks.com/topic/245029-simple-search-help-needed/#findComment-1258571 Share on other sites More sharing options...
Bradley_James Posted August 17, 2011 Author Share Posted August 17, 2011 You guys rock. Works like a dream! Thanks! Link to comment https://forums.phpfreaks.com/topic/245029-simple-search-help-needed/#findComment-1258573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.