You are here: Re: NEWBIE:Getting info out of dynamic form « PHP Programming Language « IT news, forums, messages
Re: NEWBIE:Getting info out of dynamic form

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация