Forum Moderators: coopster

Message Too Old, No Replies

Comparing Strings

Validating if almost the same record is existing

         

Francis

7:50 am on Jul 12, 2005 (gmt 0)

10+ Year Member



Hi.

My problem involves comparing a set of values- a school name. What I want to happen is to compare an inputted data from a form to a record on the database.

Because there are many ways of writing a school name, for example, St. can be written as Saint, etc. I have a problem of comparing the strings inputted with that of the record in the database.

Consider this school, St. Mary's Academy. If a user has inputted Saint Mary's Academy, the

if $var_school == $db_school {

would return False.

Is there a way for me to compare these strings in such a way that since Mary's Academy is the same, the user would be notified that there MIGHT be a similar record on the database, and display the school accordingly?

I hope that I was able to explain my problem well. Thanks a bunch.

vincevincevince

8:52 am on Jul 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First, try replacing all non-standard characters with a _ or % wildcard, and doing a LIKE query

Secondly, look at the SOUNDEX query

Francis

5:53 am on Jul 18, 2005 (gmt 0)

10+ Year Member



Hi. Thanks for the reply. But can you please be more specific on the LIKE query. I've tried the soundex() but failed to see how it will help me because as was mentioned in my question:

Consider this school, St. Mary's Academy. If a user has inputted Saint Mary's Academy, the

if soundex($var_school) == soundex($db_school) {

would return False.

I know that there might be more ways to extend this. I'm still trying to learn the ropes on this one and any extra help would be very much appreciated.

Thanks again.