Forum Moderators: open

Message Too Old, No Replies

LIKE My SQL

         

bleak26

6:27 pm on Dec 7, 2005 (gmt 0)

10+ Year Member



Hi guys and Girls of webmaster world thankyou for all your help, now we have another one for you.

We have used this statment to preform LIKE searchs in our data. When we search for "caroline" in customers.firstname the caroline record is retrived but when we search for "caroli" nothing is returned. Is there a better way to do LIKE searches or is there another method we should be using.

$sqlstatement = "select * FROM customers WHERE(customers.firstname LIKE '".$searchterm=$_POST['search']."')";

ChadSEO

6:35 pm on Dec 7, 2005 (gmt 0)

10+ Year Member



bleak26,

You need to add wildcards (%) into your Like statement, ala:

$sqlstatement = "select * FROM customers WHERE(customers.firstname LIKE '%".$searchterm=$_POST['search']."%')";

Chad