Novice question re: dynamically generated webforms and naming form
am 14.01.2008 23:36:42 von wes.waters
First post here, so please go easy on me. I'm certainly a novice at
best using PHP/MySQL.
I have a table containing ID_NO, Name, SPRIDEN_ID. This table
contains information about event attendees. This data must later be
cleansed and SPRIDEN_ID should be added to this table if the attendee
is a constituent of ours or set to NULL (rather than deleted) if they
are not a constituent.
Since I am using MySQL and PHP I have created a web form that allows
the data to be cleansed. The PHP page simply extracts all attendee
information where the SPRIDEN_ID is not NULL or = 0 (as the column is
defined as INT, this is the default) and creates a php table where
each row provides the option to 1. input a SPRIDEN_ID in a text field
or 2. mark the SPRIDEN_ID as null via a checkbox. The user should
have functionality that will allow them to cleanse however many rows
they so choose in one sitting, adding SPRIDEN_ID or marking SPRIDEN_ID
as NULL until an indefinite point, then press submit and have the
updates applied using MySQL to the database table, whether they have
cleansed all the rows of data or not.
Since this is a webform that is built off dynamic content, it creates
a row in the php table for every row in the database table where the
SPRIDEN_ID meets the above criteria. The field names, however, are
named the same thing over and over. I have found that this does not
work well, as the $_POST array reads these are key collisions and only
stores the final instance. What is the optimal way to name my form
fields here? Should I prepend an iterated number to each form field
name and then split it out into an associative array while reading the
$_POST data? Should I use php EXTR_PREFIX_ALL?
I have found little documentation on this problem and have been
searching for awhile. Any help would be greatly appreciated.
Re: Novice question re: dynamically generated webforms and namingform fields
am 14.01.2008 23:58:45 von Jerry Stuckle
wes.waters@gmail.com wrote:
> First post here, so please go easy on me. I'm certainly a novice at
> best using PHP/MySQL.
>
> I have a table containing ID_NO, Name, SPRIDEN_ID. This table
> contains information about event attendees. This data must later be
> cleansed and SPRIDEN_ID should be added to this table if the attendee
> is a constituent of ours or set to NULL (rather than deleted) if they
> are not a constituent.
>
> Since I am using MySQL and PHP I have created a web form that allows
> the data to be cleansed. The PHP page simply extracts all attendee
> information where the SPRIDEN_ID is not NULL or = 0 (as the column is
> defined as INT, this is the default) and creates a php table where
> each row provides the option to 1. input a SPRIDEN_ID in a text field
> or 2. mark the SPRIDEN_ID as null via a checkbox. The user should
> have functionality that will allow them to cleanse however many rows
> they so choose in one sitting, adding SPRIDEN_ID or marking SPRIDEN_ID
> as NULL until an indefinite point, then press submit and have the
> updates applied using MySQL to the database table, whether they have
> cleansed all the rows of data or not.
>
> Since this is a webform that is built off dynamic content, it creates
> a row in the php table for every row in the database table where the
> SPRIDEN_ID meets the above criteria. The field names, however, are
> named the same thing over and over. I have found that this does not
> work well, as the $_POST array reads these are key collisions and only
> stores the final instance. What is the optimal way to name my form
> fields here? Should I prepend an iterated number to each form field
> name and then split it out into an associative array while reading the
> $_POST data? Should I use php EXTR_PREFIX_ALL?
>
> I have found little documentation on this problem and have been
> searching for awhile. Any help would be greatly appreciated.
>
First of all, NULL is not the same as 0. 0 is a value. NULL is
specifically the lack of a value, and is handled differently.
As to your problem - does each row have a unique id (primary key)? If
not, it should have.
I normally build the name of the checkbox by concatenating the id to a
prefix. Then it's an easy job to split off the id which needs to be
checked.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Novice question re: dynamically generated webforms and naming
am 15.01.2008 01:25:04 von wes.waters
Right. The SPRIDEN_ID column is int(8) and nullable. The default
value is 0, but the column can contain NULL.
Each row does have a unique identifier and I certainly can concatenate
the ID to the name of this field. Do you recommend this as the
optimal solution?
Re: Novice question re: dynamically generated webforms and naming form fields
am 15.01.2008 01:43:05 von Jerry Stuckle
wes.waters@gmail.com wrote:
> Right. The SPRIDEN_ID column is int(8) and nullable. The default
> value is 0, but the column can contain NULL.
>
> Each row does have a unique identifier and I certainly can concatenate
> the ID to the name of this field. Do you recommend this as the
> optimal solution?
>
That's how I do it.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================