Re: Variables in forms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ron Piggott wrote:
I am writing a form right now.
I would like to make the checkbox an array variable.  The first part of
the array is the component reference, the second part is the package
reference.  What name would you assign to it that I could use in
processing the form in the PHP script this posts to?
Ron

<tr>
<td valign="top"><font face="times new roman"><center>Children's Activities</center></td>
<td valign="top"><font face="times new roman"><center>Child's ABC's</center></td>
<td><center><input type="checkbox" name="component_1_package_1"></center></td>
<td><center><input type="checkbox" name="component_1_package_2"></center></td>
</tr>



In your form, do this

<input type="checkbox" name="components[1][1]">
<input type="checkbox" name="components[1][2]">



Then in PHP do this.  This is if the form was sent via POST

<?php

$components = your_cleaning_function($_POST['components']);

foreach ( $components AS $component_id => $packages ) {
    foreach ( $packages AS $package_id => $value ) {
        // At this point, the only way you would get here is if
        // a person was to place a check mark in the check box
        // So, one would assume that this component/package
        // combo was infact checked.
    }
}

?>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux