|
Posted by Mike on 10/10/73 11:51
I have set up a simple search in PHP. The user enters some text and
this is then searched for in a MySQL database. If the text is found
within the database, the whole text is displayed, highlighting what the
user entered in red....
Basically...
User enters text in a text box. Result stored as textsearch.
//perform the search in the database
$sql = "select * from mytable where textfield like
'%$_POST[textsearch]%'";
//If found the result of the textfield is stored as $searchres,
changing all occurance of the user entered text to red
$searchres = str_replace("$_POST[textsearch]","<font
color=#FF0000><strong>$_POST[textsearch]</strong><font
color=#000000>",$searchres);
//$searchres is echo'ed
All this works great except if the textfield contains for example
'School' and the user searches on 'school' it won't find it.
I could use various function such as strtolower() etc and try all
possibilities but is there an easier way ignore the case so the search
with pick up both 'School' and 'school'?
Many Thanks
Mike
Navigation:
[Reply to this message]
|