> -----Original Message----- > From: Floyd Baker [mailto:[EMAIL PROTECTED]] > Sent: 28 November 2002 17:09 OK, I think I'm finally beginning to understand what you're up to, and it seems to me everyine's been making rather heavy weather of it so far!
> The user's choice is made from a drop down list of available items, > prior to running the routine itself. The choices are predetermined > and kept in a personal table to be called by the routine. This part > is finished to the point of putting the needed column names at the top > of the input columns on the form. The choices are fixed spellings to > match formula if-then's, etc. If this is the case, couldn't you use 2-dimensional arrays with the column names as the first dimension, and the values relating to it in the second dimension? So you'd have something like $user['colour'][0] $user['hobby'][0] $user['etc'][0] $user['colour'][1] $user['hobby'][1] $user['etc'][1] $user['colour'][2] $user['hobby'][2] $user['etc'][2] $user['colour'][3] $user['hobby'][3] $user['etc'][3] etc. Anyway, going back to your forms: > >if ($start_button=="1") > > { > > print "<form action=$PHP_SELF method=get>"; > > print "Input the following information"; > > // these are your fixed cells and they now contain user input > > print "Name: <input type=text name=name value=\"$name\" > size=20><br>"; > > print "Temp: <input type=text name=temp value=\"$temp\" > size=20><br>"; > > print "Time: <input type=text name=time value=\"$time\" > size=20><br>"; > > print "Offset: <input type=text name=offset value=\$offset\" > >size=20><br>"; > > print "Input the names of the desired additional cells in the spaces > >provided."; > > // this is where your user will name the cells he asked to create > > for($i=1;$i<=$additional_cells;$i++) > > { > > print "$i <input type=text name=user_added[$i] size=20><br>"; > > } OK, this looks good -- it will give you your array of column names. But you really should quote all those attributes, so: print "$i <input type=\"text\" name=\"user_added[$i]\" size=\"20\"><br>"; The next bit is where I'd do the clever stuff to build the 2-dimensional array: > >> Name Temp Time Offset Etc. As needed... > >> process 1 [input] [input] [input] [input] [inputs] > >> process 2 [input] [input] [input] [input] [inputs] > >> process 3 [input] [input] [input] [input] [inputs] > >> process 4 [input] [input] [input] [input] [inputs] > >> > >> Right now, for the three *basic* columns, I have the lines > below in a > >> 'while' loop. > >> > >> <INPUT TYPE='text' NAME='temp[]' VALUE='$temp' SIZE='10' > >> MAXLENGTH='10'> > >> <INPUT TYPE='text' NAME='time[]' VALUE='$time' SIZE='10' > >> MAXLENGTH='10'> > >> <INPUT TYPE='text' NAME='offs[]' VALUE='$offs' SIZE='10' > >> MAXLENGTH='10'> So, you just need additional lines in your while loop to add the entries for the user columns, named in such a way that you'll get back the 2-dimensional array I described earlier. As you already have those column namers in the $user_added[] array built above, we can do it like this: foreach ($user_added as $user_col): echo "<input type='text' name=\"user['$user_col'][]\" size='10' maxlength='10'>"; endforeach; and, bingo, you have your user's input being submitted into a 2-dimensional array indexable by column name and row number. (Actually, to be absolutely sure all the row numbers match, I'd be outputting those into the form field names as well.) Additionally, having gone this far I'd consider doing the same sort of thing with your standard columns, something like this: $std_cols = array('temp', 'time', 'offs'); // now fill the $user_added[] array from database or wherever echo "<form ......>"; for ($n=0; $n<ROWS_NEEDED; $n++): foreach ($std_cols as $col_id): echo "<input type='text' name=\"$col_id[$n]\" size='10' ....>"; endforeach; foreach ($user_added as $col_id): echo "<input type='text' name=\"user['$col_id'][$n]\" size='10' ....>"; endforeach; endfor; You could even 2-dimensionalize your standard columns, so you get: $std['temp'][0] $std['time'][0] $std['offs'][0] $std['temp'][1] $std['time'][1] $std['offs'][1] etc., with the corresponding form fields being written using: foreach ($std_cols as $col_id): echo "<input type='text' name=\"std['$col_id'][$n]\" size='10' ....>"; endforeach; And, then, of course, you might well wonder why you should bother having two separate sets of very similar arrays, when you could merge them and just keep track of how many are standard ones (with the rest automatically treated as user added ones). So you'd start off something like: $cols = array('temp', 'time', 'offs'); define('N_STD_COLS', 3); and build from there -- but I leave that as an exercise for the reader!!! Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php