I'm currently just using '%$search_string%', which is fine, but obviously if the user searches for 'car', they also get 'McArthur's Newsagent, etc.
I've absolutely no experience of regular expressions; it looks like I need to use ^ and $ at some point, but I'm not sure where, and what the syntax should be.
Below is a simplified version of some of my code. Should I be using regex at the begginning where I define my variables, or within the query? Any pearls of wisdom would be hugely appreciated.
Code: Select all
$businesstype = ($_GET['businesstype']);
$query = "SELECT * FROM business_directory WHERE Name LIKE '%$businesstype%' OR (Type LIKE '%$businesstype%' OR Keywords LIKE '%$businesstype%')";