Wednesday, 2 October 2013

Simple query to search a terms in MySQL

Simple query to search a terms in MySQL

I build a little search input in my site, its kind of working, the problem
is that it show all the items as results, so it isnt really searching, it
just throw all the table..
my query look like this
// Get page data
$query1 = "SELECT id,tienda,descripcion,local,img FROM $tableName WHERE
tienda LIKE '%$term%' ";
$result = mysql_query($query1)or die(mysql_error());
if i remove the % symbol of $term , then i got "no results" , so what am i
missing.
What i need is to search for exact and partial coincidences, for example,
"Go" should throw "google" as result..
thanks,

No comments:

Post a Comment