girish.kc Posted April 8, 2011 Share Posted April 8, 2011 Hello, I have a Phone number lookup in my website. The number in table may be in different formats like (123) 456 - 789 OR 123-456-789 OR 123456789 OR 123 456 789 etc.. But now how to search the numbers from the table. If the user enters 123456789 it should select the record with this number in any format. Please help. Girish Quote Link to comment https://forums.phpfreaks.com/topic/233055-searching-phone-number/ Share on other sites More sharing options...
mrqpro Posted April 8, 2011 Share Posted April 8, 2011 I think in this case. The best way is change your database structure. You have to add a field named real_phone. When insert a record you have to remove all character from phone number and insert this value to real_phone field. When searching. You have to handle the data to search only contain number and compare with real_phone field Good luck. Quote Link to comment https://forums.phpfreaks.com/topic/233055-searching-phone-number/#findComment-1198721 Share on other sites More sharing options...
girish.kc Posted April 12, 2011 Author Share Posted April 12, 2011 Thanks, I'm using the following : phone_number like '%1%2%3%4%' to search for the phone number. Quote Link to comment https://forums.phpfreaks.com/topic/233055-searching-phone-number/#findComment-1200431 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.