Jump to content

Archived

This topic is now archived and is closed to further replies.

pgsjoe

multiple entries, one form

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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.