Jump to content

Forms that input data to MySQL tables


TomFromKWD

Recommended Posts

Guys, quick one.

 

Im writing a script for a form to post info into a MySql table.

 

Now rather than just having a single row for input I'd like to have lets say 10 rows, so I can add 10 records to the database.

 

What I'm pondering is 2 things:

 

1: can i just repeat

<input type="text" name="opponent" size="27" />

over and over, or is it going to need its own name each time for example;

<input type="text" name="opponent2" size="27" />
<input type="text" name="opponent3" size="27" />

 

2: when it comes to the processing script is it more economical to have the forms input field named the same over and over (if it IS possible) and if not whats the most econimcal way to code my

$opp= $_POST['opponent'];
$query="INSERT INTO fixtures (match_date, season, opponent) VALUES ('$date', '$season', '$opp',)";

 

 

Your help and comments are appreciated as always guys

 

Tom

Link to comment
https://forums.phpfreaks.com/topic/230318-forms-that-input-data-to-mysql-tables/
Share on other sites

Use type array <input type="text" name="opponent[]" size="27" />

 

Makes sense, but just to clarify, with that, my php script to update the table with form data would still read

 

$opp= $_POST['opponent'];

$query="INSERT INTO fixtures (match_date, season, opponent) VALUES ('$date', '$season', '$opp',)";

 

correct?

Archived

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

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