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

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.