Multiple entries in one table

Discussion in 'Web Design and Development' started by DaReal_Dionysus, Jul 8, 2009.

  1. DaReal_Dionysus macrumors regular

    DaReal_Dionysus

    Joined:
    Jan 9, 2009
    #1
    Is there a way with php to enter multiple entries of data in to one table.

    Example. if a person wants to enter multiple events on different date and time, but all at once.
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    You're going need to provide more info. Are you talking about an HTML table or a MySQL table? What are you doing e.g., the context you're working in?
     
  3. DaReal_Dionysus thread starter macrumors regular

    DaReal_Dionysus

    Joined:
    Jan 9, 2009
    #3
    You not kidding!!! i just read my post and it was way too vague. Sorry about that AW.

    Let me try again.

    I am using PHP/MySQL and what I'm trying to accomplish is a way for me to insert multiples entries of data into a single MySQL table.

    Example: The client is a golf course and he sells teetimes. I want him to be able to enter the teeimes for different times and dates.

    Example of a tee time:
    Date: 01/02/2002 Time: 2:30 P.M. Players: 1 to 4
    Date: 01/02/2002 Time: 2:40 P.M. Players: 1 to 4
    Date: 01/02/2002 Time: 2:50 P.M. Players: 1 to 4
    Date: 01/03/2002 Time: 3:50 P.M. Players: 1 to 4
    Date: 01/03/2002 Time: 4:50 P.M. Players: 1 to 4
    Date: 01/03/2002 Time: 5:50 P.M. Players: 1 to 4

    what i want to to accomplish is a way for the client to be able to enter all these times at once. But show up as separate items in a search and in the cart for purchasing.

    Thanks guys

    Neon
     
  4. NathanCH macrumors 65816

    NathanCH

    Joined:
    Oct 5, 2007
    Location:
    Stockholm, Sweden
    #4
    Just have multiple inserts in your php code. Simple as that
     
  5. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #5
    Like NathanCH said, you can just make multiple queries to add to your DB tables. I use to think having so many calls to the DB on a single script would be slow, but it really isn't especially since you be able to keep the same connection open while you do the additions. So you'll just have a loop and enter each entry until you're done.

    Alternatively, if the client doesn't really need to enter multiple records at once without sending the data you can just have a single record form and they submit as they enter the data. It wouldn't really slow them down I wouldn't think, but I don't know all the details either.

    Though, if you really feel you need the ability to insert multiple records in one query, here's how.

    PHP:
    $sql "INSERT INTO teetime (date, time, players)
      VALUES
      (2002-01-02, 14:30, 2),
      (2002-01-03, 15:30, 4),
      (2002-01-03, 17:30, 3)"
    ;
    (from: http://www.desilva.biz/mysql/insert.html)
     
  6. DaReal_Dionysus thread starter macrumors regular

    DaReal_Dionysus

    Joined:
    Jan 9, 2009
    #6
    Yes yes yes, brain fart guys. Thanks guys. I actually know that and I have know idea where my brain is lately. In my rear at this point lol. Thanks Guys that was exactly what i needed to get the brain going again.

    NeonDork
     

Share This Page