Page 1 of 1

PHP MYSQL LIKE

Posted: Thu Apr 17, 2008 9:53 pm
by anser316
The user types something in a textbox.
e.g. s3

Code: Select all

echo "<td><input type=text name=dname></td>";
$dname=$_POST(dname);
This is the end of MYSQL statement
AND dname LIKE '%$dname%'.

If i wanted to get 'sample3', s3 will not work, because the letters have to be together, 'sam' would work.
how can i get 'sample3' from typing in 's3'

Re: PHP MYSQL LIKE

Posted: Thu Apr 17, 2008 10:10 pm
by Christopher
You could split up $dname at the first non-letter and then do AND (dname LIKE '$dstart%' OR dname LIKE '%$dend').