Jump to content

multiple entries, one form


pgsjoe

Recommended Posts

I'm sure there's a name for what I'm looking for, I just don't know it, or how to do it. Basically, I have a form for people to enter their teams. So they would put the name for team, then each person's name, e-mail and phone. I then want these to enter into the database in 4 fields. Team Name, Name, E-mail, Phone...but for each person. So how would I do such a thing? Thanks in advance. I really appreciate it.
Link to comment
Share on other sites

form.htm
[code]<form action="update_db.php" method="POST">
<!-- <1> -->
<input type="text" name="1team">
<input type="text" name="1name">
<input type="text" name="1email">
<input type="text" name="1phone">
<!-- </1> -->
<!-- <2> -->
<input type="text" name="2team">
<input type="text" name="2name">
<input type="text" name="2email">
<input type="text" name="2phone">
<!-- </2> -->
<!-- <3> -->
...
<!-- </3> -->
</form>
[/code]


update_db.php
[code]<?php
$max=3; //the number of "Sets" we got
$i=1;
while($i<=$max){
$team=$i."team";
$name=$i."name";
$email=$i."email";
$phone=$i."phone";
mysql_query("INSERT INTO `table_name` VALUES ('$team', '$name', '$email', '$phone')");
}
?>[/code]

Of course you need to add validation, SQL injection protection etc'. But that's the main idea :)

Orio.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.