I have a search function on a page that when the user types in a search term when submit is pressed it checks the database and shows appropriate records in the database (it uses a %Like% query) on the page.
However the user may spell something wrong. Is there anyway it can still search the database and show some results. I.e. Colour is stored in the database however the user searches color - is there any way we can change the WHERE clause to make sure that Colour is pulled through?
Code is below:
//// Contains the search term from the form
$searched_club = $_GET['username'];(form is a PHP_SELF)
if($searched_club == ''){
$sql = "SELECT name, region FROM jos_users ORDER BY id DESC LIMIT 6";
}else{
$sql = "SELECT name, region FROM jos_users WHERE name LIKE '%$searched_club%'";
}
$rsd = mysql_query($sql, $dbconn);
<table>
while($rs = mysql_fetch_array($rsd)) {
$name = $rs['name'];
$region = $rs['region'];
?>
<tr>
<td><?php
echo $name;
?></td>
<td><?php
echo $region;
?></td>
</tr>
<?php
}
?>
</table>