Searching within a field.

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Searching within a field.

Post by Gen-ik »

I have a MySQL Database with a load of website member names as part of it. This DB is used to check members usernames and passwords when they sign-in.

What I am planning to do is insert <font color=#ff6600> before their username, and </font> after it... within the actual database.

Now, is it possible to search the usernames but ignore the two font tags?

I have to include the font tags in the database because the usernames get pulled from it all over the site, and over several sites.

Re-coding each and every page that displays usernames is not an option.


Is it possible... or should I cry?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you might add the tag to your search, e.g.

Code: Select all

$query = 'SELECT ... WHERE login='''.mysql_escape_string('&lt;font color=#ff6600&gt;'.$login.'&lt;/font&gt;').'''';
or select with a LIKE statement and check later stripping the tags.
But this is a dirty hack, so if someone asks; I didn't tell you Image
Post Reply