You are here: Ignoring Case « All PHP « IT news, forums, messages
Ignoring Case

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация