I am creating a search function on a website I am working on.
Of course when a user searches something, he doesn't usually type in the exact text he wants to search, but wants to get similar results too.
However my query only searches for the exact string put in the search box.
How can I change this, so that it searches for similar values and orders them by relevance??
Here is my query:
Code: Select all
<?php
$search = $_GET["search_query"];
$con = mysql_connect("localhost","*****","*****");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_kitchentube", $con);
$result = mysql_query("SELECT * FROM videos
WHERE title = \"$search\"");
while($row = mysql_fetch_array($result))
{ ?>
RESULTS GET DISPLAYED HERE
<?php
}
mysql_close($con);
?>