What search algorithm should I use to give results when a user searches for a title of a book?
If there exists a book that title should be returned otherwise the book titles that are close to it have to be displayed.
The first case is easier just searching a string. I need how to solve the second case which most of the websites use.
The books table contains fields category, class and title. I have tried the below code and I am getting results when I give exact title I want the system to give titles that are closely related.
$title=isset($_GET['title'])?$_GET['title']:NULL;
//$code=isset($_GET['code'])?$_GET['code']:NULL;
$class=isset($_GET['class'])?$_GET['class']:NULL;
$cat=isset($_GET['category'])?$_GET['category']:NULL;
if(isset($title))
$qry="select * from books where quantity>0 and title='$title' ";
else{
$qry="select * from books where quantity>0 ";
if(isset($class)) $qry.=" and class='$class' ";
if(isset($cat)) $qry.=" and category='$cat' ";
}