I'm working on a small FAQ site with a Searchfunction
Right now i use SQL and search for the right entry like this:
<form action="search.php" method="get">
<label>
Search
<input type="text" name="keywords" autocomplete="off">
</label>
<input type="submit" value="Search">
</form>
<?php
require_once '../db/connect.php';
if (isset($_GET['keywords'])&& empty($_GET['keywords']) === false) {
// code...
$keywords = $connection->real_escape_string($_GET['keywords']);
$query = $connection->query("
SELECT question, answer
FROM FAQ
WHERE tags LIKE '%{$keywords}%'
");
?>
When i search for "WLAN" it shows the entry where i have "Wlan, Connection, ..." in the tags. When i search for Connection it shows the same entry. Great so far! But when i search for "Connection with WLAN" it doesn't work... obviously. Is there an easy method to implement this?
It would be something like '%{$keywords}%' where i can say it just has to be equal to some part of the string.
Any ideas?