View Full Version : attach multiple numbers and store in db
i have a simple form consisting of name, tel_no, mob_no, sales, flag which gets sent and stored in a mysql database and an email get sent as well.
however each customer could have upto 100 telephone numbers is there any way of allowing a user to add upto 100 telephone numbers for one customer and also store each different telephone number as a new record in the database?
any help would be great
thanks in advance.
11-28-2006, 01:19 PM
do you really need each each telephone number to have its own row in your DB?...I would use some kind of delimiter, and store all 100 phone numbers in the same row/cell, so a row might look like this (you get the idea, hopefully):
Joe Smith 354-533-5590|345-694-6909|293-578-0943 mob_no sales flag
When you call the row information from the database, you can use explode() (http://us2.php.net/manual/en/function.explode.php) to get each individual numner into an array:
$phone_nos = explode("|", $row['tel_no']);
echo $phone_nos; // 354-533-5590
echo $phone_nos; // 345-694-6909
echo $phone_nos; // 293-578-0943
11-28-2006, 02:45 PM
do you really need each each telephone number to have its own row in your DB?
It's a good idea in general.
Having the phone numbers in a seperate table would allow you to select only these that you need, not all, to search them and sort them.
11-28-2006, 09:57 PM
Personally, I would save myself the effort (and space, perhaps) of having to create a new table for each name in my database that only stored that person's phone numbers, when I could just as well search and sort the person's phone numbers array in PHP...but to each his/her own, I guess...:)
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.