Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

DaReal_Dionysus

macrumors regular
Original poster
Jan 9, 2009
226
0
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.
 
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?
 
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?

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
 
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)
 
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)

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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.