Page 1 of 1

Basic search script

Posted: Fri Feb 13, 2004 3:47 pm
by josh
I have a database of books and I was wondering how to implement a basic search script, I guess what I am asking is how do I see the % of similarity between term 1 and term 2, would there be a better way... perhaps does term1==term2 but if they are searching star wars I would want star wars 1 2 3 4 5 6 and 7 etc... you get what I mean?

Posted: Fri Feb 13, 2004 3:53 pm
by tsg

Posted: Sat Feb 14, 2004 2:36 pm
by basdog22
You can do a simple replace:

Code: Select all

<?php
$squeryreplaced=str_replace(" ","%') or (story like '%",$squerylow);     //if the user give 2 search terms ???

$query=mysql_query("select * from news where (story like '%$squeryreplaced%')");
?>
Change "news" with the name of your table
You can change "story" with books or whatever you want to search for
$squerylow is the value that holds the terms the user used :wink: