hi i’m having a little trouble trying to retrieve the data sent in a form. The problem i have is that i want the user to be able to specify data for X amount of rows (the amount of rows are also specified by the user) and then upload them to the database. The text input fields are created by:
[code=php]
$fields = 1;
$count = 0;
while ($count != $no_of_fields)
{
echo ‘<label>’.$fields.’. </label><input type=”text” size=”50″ maxlength=”50″ name=”‘.$fields.'” /><br />’;
$count++;
$fields++;
}
And my initial thoughts were that as the name of each field would be a number (starting with 1, and in turn field 1 would be accessed by the variable $1 when submitted), i could use a while loop. The while loop would count against the number of rows originally specified by the user to run code to enter each row into the database.
The problem now lies with the naming of the input fields: If the user specifys 5 rows to be added, when the form is submitted the contents of the fields will be stored in variables $1, $2, $3, $4 & $5. Which is fine untill i want to read these in a while loop where i need to vary the variable name. Is that possible? I don’t think it is, so my next plan was to have the contents of each field put into a single array and then use a while loop to read entry one at a time….i’m not to hot on the creation and usages of arrays at the best of times – any one want to point me in the right direction?
Would changing <input type=”text” size=”50″ maxlength=”50″ name=”‘.$fields.'” /> to <input type=”text” size=”50″ maxlength=”50″ name=”array[‘.$fields.’]” /> cause the results to be put in $array?
Cheers, Durbs
P.S. Sorry if that makes no sense what-so-ever…