Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Kal
    Kal is offline
    Regular Coder
    Join Date
    Dec 2005
    Posts
    309
    Thanks
    0
    Thanked 0 Times in 0 Posts

    attach multiple numbers and store in db

    Hi Guys,

    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.

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,795
    Thanks
    19
    Thanked 156 Times in 147 Posts
    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() to get each individual numner into an array:

    PHP Code:
    $phone_nos explode("|"$row['tel_no']);
     echo 
    $phone_nos[0]; // 354-533-5590
     
    echo $phone_nos[1]; // 345-694-6909
    echo $phone_nos[2]; // 293-578-0943 
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by chump2877 View Post
    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.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #4
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,795
    Thanks
    19
    Thanked 156 Times in 147 Posts
    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...
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •