Jump to content

[SOLVED] Telephone Database


yoki

Recommended Posts

Hi,

 

I'm rather new to setting up a MySQL database and was wondering if someone could suggest me a way of storing phone numbers.  I'm planning to update my database with a .csv file which will contain the phone numbers in this format:

 

514,2544395

514,6549082

.

.

.

 

I want to be able to search for a phone number by first selecting the area code in a dropdown and then entering the number in another field.

 

Should I split the telephone number into two tables?  One table for the area code and one for the telephone number?

 

Any good suggestions would be appreciated.

Link to comment
https://forums.phpfreaks.com/topic/129409-solved-telephone-database/
Share on other sites

I'd just store them as

 

5142544395

5146549082

 

You can find all the 514 numbers with

 

SELECT phone FROM table WHERE phone LIKE '514%'

 

Also, you can get the area codes for your dropdown with

 

SELECT DISTINCT LEFT(phone, 3) as areacode FROM table

 

You can format on output with something like this

http://www.phpfreaks.com/forums/index.php/topic,208588.msg948466.html#msg948466

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.