|
Posted by Steve on 10/08/05 23:43
> while ($row = mysql_fetch_array ($result)){
> print"<input name='".$row['id']."' size='4' type='text'
> value='".$row['id']."'/>";
> print"<input type='text' size='10' value='".$row['date']."'/>";
> print"<input type='text' size='6' value='$measure'/>";
> print"<input type='hidden' size='10' value=''/>";
> But I am sbsolutely stumped as to how to get the information out of the
> form. Any pointers would be greatfully received.
You are creating one form with fields for many records, but some of the
field names are unique, some of them are duplicated and some of them
are absent (no name at all).
When a user clicks on the submit button the field values will be
gathered up and passed to the processing script as members of the
$_POST array.
There will be one entry for each unique name in the $_POST array; so
there will be one and only one entry each for the duplicated names,
probably containing the value of the last record in the form; and there
will be nothing in the $_POST array for any fields that have no name.
To fix this, give each field across a record a unique name - forget the
dynamic names, you can identify the record by the /value/ of the id
field - but make them arrays - that is, append square brackets [] to
the names. This will cause PHP to keep the values for each record apart
and stop them being overwritten by the next set of values from the
following record.
To disentangle the data when you receive many records lumped into one
submission manage the data in a similar loop to the one that created
the form, with each pass through the loop updating the values for one
database record.
---
Steve
[Back to original message]
|