TomFromKWD Posted March 11, 2011 Share Posted March 11, 2011 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 Quote Link to comment Share on other sites More sharing options...
zenag Posted March 11, 2011 Share Posted March 11, 2011 Use type array <input type="text" name="opponent[]" size="27" /> Quote Link to comment Share on other sites More sharing options...
TomFromKWD Posted March 11, 2011 Author Share Posted March 11, 2011 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? Quote Link to comment Share on other sites More sharing options...
zenag Posted March 11, 2011 Share Posted March 11, 2011 Use "implode" method $opp= implode(',',$_POST['opponent']); Quote Link to comment Share on other sites More sharing options...
TomFromKWD Posted March 11, 2011 Author Share Posted March 11, 2011 palm to face right now! Thankyou kindly, just had a brain freeze and couldn't get it right in my head Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.