PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$kwd=$_POST['keyword'];
$query = "SELECT * FROM item WHERE item_name LIKE '%".trim($kwd)."%' ";
$result= mysql_query($query, $connect) or die('Query failed: ' . mysql_error());
for example if i look for nokia i have a list of all items with this name
but if i look for nokiia it doesn't return any results
is there something missing in the query?
LIKE %stuff% means anything that has 'stuff' in the middle of it 'hhjjkhstuffdsds' would match and so would 'stuff house'. However 'stuuff' would not match.
FYIOMG your query is very insecure, never take something from $_POST and just shove it into a query.
just a quick note... Soundex doesn't work well with anything other than english.
Using the pspell functionality you could check the spelling after an empty search and find searches from any suggestions from the pspell if no results found.
Using the post value without any validation allows something called SQL Injection attacks to occur. At it's simplest ... what happens if you search for