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 Quote 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. Quote 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"; Quote 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! Quote Link to comment https://forums.phpfreaks.com/topic/245029-simple-search-help-needed/#findComment-1258573 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.