RE: [PHP] Scrolling through values sent from a form[scanned]
| From: | John W. Holmes | Date: | Sun, 16 Mar 2003 22:42:06 +0000 |
| Subject: | RE: [PHP] Scrolling through values sent from a form[scanned] | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139877@lists.php.net to get a copy of this message | ||
Don't rely on checkboxes. If they are not checked, as you've found out I
think, then the value is not set at all. Use a hidden value to carry
over a key for each field, then check the checkbox to see whether it was
checked or not.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
> -----Original Message-----
> From: shaun [mailto:shaun@mania.plus.com]
> Sent: Sunday, March 16, 2003 1:16 PM
> To: php-general@lists.php.net
> Subject: [PHP] Scrolling through values sent from a form
>
> Hi,
>
> i have a form on a page which is built dynamically and consists of
fields
> in
> a certain table and checkboxes. The puropse of the form is to update
the
> the
> status of a table called CMS_FIELDS which stores data of all the
fields
> for
> all the tables in the database.
>
> Using the following code i am attempting to update the table depending
on
> whether the boxes have been ticked or not, but the script only outputs
> values of the boxes that have been ticked. (the data isn't being
updated
> yet
> i am just printing it to the screen for testing purposes).
>
> if(isset($update_fields)==true){
> $fields='';
> $values='';
> foreach ($_POST as $key => $val) {
> $fields[] = $key;
> $values[] = $val;
> }
> $i=0;
> foreach ($fields as $val){
> if ($values[$i] == "on"){
> $query = "UPDATE CMS_FIELDS SET cms_fields_is_editable = '1'
> WHERE cms_table_name = '$_GET[table_name]' AND
> cms_field_name
> = '".$fields[$i]."'";
> }else {
> $query = "UPDATE CMS_FIELDS SET cms_fields_is_editable = '0'
> WHERE cms_table_name = '$_GET[table_name]' AND
> cms_field_name
> = '".$fields[$i]."'";
> }
> echo "$query<br>";
> $i++;
> }
> }
>
> How can i get the script to look at all of the values sent from the
form
> (ticked or unticked)?
>
> thanks for your help
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php