What is the best way to build a mySQL & PHP search?
I am currently using things like
%term%
I want it to be able to
Simple, Smart and Secure
As timpng1 put an example on Ajreal Answer above I'd like to make it Secure.
$conn = new mysqli('server', 'username', 'password', 'dbName');
$q = $conn->real_escape_string($_GET["query"]);
$sql = $conn->prepare("SELECT *, MATCH(col1, col2) AGAINST(? IN BOOLEAN MODE) AS relevance FROM my_table ORDER BY relevance DESC LIMIT 20");
$sql->bind_param("s", $q);
$sql->execute();
$rs = $sql->get_result();