Jump to content


Photo

multiple entries, one form


  • Please log in to reply
2 replies to this topic

#1 pgsjoe

pgsjoe
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 31 August 2006 - 02:24 AM

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.

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 31 August 2006 - 07:19 AM

form.htm
<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>


update_db.php
<?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')");
}
?>

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

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 pgsjoe

pgsjoe
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 31 August 2006 - 06:36 PM

YES! That's exactly what I was looking for. You rule. Thank you.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users