Re: Ignoring Case
- From: "Rik" <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Wed, 28 Jun 2006 14:50:54 +0200
Mike wrote:
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....
All this works great except if the textfield contains for example
'School' and the user searches on 'school' it won't find it.
Aren't you finding them in the database either?
Look at FullText Search:
http://www.phpfreaks.com/tutorials/129/0.php
http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html
Case-insensitive by default, and highly versatile
$searchres = str_replace("$_POST[textsearch]","<font
color=#FF0000><strong>$_POST[textsearch]</strong><font
color=#000000>",$searchres);
Don't use <font>, it's deprecated.
Use <span> with css, or better, create a class "highlight".
Like Janwillem sais:
str_ireplace() with PHP >= 5 offcourse.
Regex in PHP < 5:
$string = preg_replace('/('.preg_quote($search).')/i','<span
class="highlight">$1</span>',$string);
Grtz,
--
Rik Wasmus
.
- Follow-Ups:
- Re: Ignoring Case
- From: Mike
- Re: Ignoring Case
- References:
- Ignoring Case
- From: Mike
- Ignoring Case
- Prev by Date: Re: Help - Outputting Thumbnails
- Next by Date: Re: Why php ?
- Previous by thread: Re: Ignoring Case
- Next by thread: Re: Ignoring Case
- Index(es):
Relevant Pages
|