I am developing a classifieds site. For searching product or company I am using wildcard (%) in both in front and back.
$keyword = "%".$user_keyword."%";
And I am using the following mysql query:
$query = "SELECT DISTINCT login.id_user,
login.company,
login.district,
FROM login LEFT JOIN products
ON login.id_user = products.id_user
WHERE (login.district LIKE ?
AND login.place LIKE ?)
AND
(login.company LIKE ?
OR login.summary LIKE ?
OR products.description LIKE ?)
LIMIT ?, ?";
";
This is working. But I want to sort the list with reference to the keyword. For eg: If an user search for "foo" the following result may be get:
fool
kafoo
safoora
foo
foolan
I want to get "foo" as the first item