Been working on a little search option. When I enter a single word into the search it brings up all the results related to the word. However, with two or more word phrases the search fails to bring up results. The SQL code looks fine to me: (a.posttitle LIKE '%$keywords%' OR a.post LIKE '%$keywords%') What could be the problem? The spaces between the words? Maybe there's another way of doing this (instead of LIKE %%)?
do something like this (untested, typed quickly) $bits = explode(' ', $keywords) $where = []; foreach($bits as $bit){ $where[] = ' a.posttitle LIKE '%bit%'; $where[] = ' a.post LIKE '%bit%'; } $sql = "select a.id, a.posttitle, a.post from a where a.status = 'published' and (". implode(' OR ', $where) . ') order by a.posttitle'; Code (php):