Novice question re: dynamically generated webforms and naming formfields

This is a discussion on Novice question re: dynamically generated webforms and naming formfields within the PHP Language forums, part of the PHP Programming Forums category; First post here, so please go easy on me. I'm certainly a novice at best using PHP/MySQL. I ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-14-2008
wes.waters@gmail.com
 
Posts: n/a
Default Novice question re: dynamically generated webforms and naming formfields

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.
Reply With Quote
  #2 (permalink)  
Old 01-14-2008
Jerry Stuckle
 
Posts: n/a
Default Re: Novice question re: dynamically generated webforms and namingform fields

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
==================

Reply With Quote
  #3 (permalink)  
Old 01-15-2008
wes.waters@gmail.com
 
Posts: n/a
Default Re: Novice question re: dynamically generated webforms and namingform fields

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?
Reply With Quote
  #4 (permalink)  
Old 01-15-2008
Jerry Stuckle
 
Posts: n/a
Default Re: Novice question re: dynamically generated webforms and namingform fields

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
==================

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:58 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0