Ron,

One option is to build a list of privs and iterate over that for the form
and processing

To do that, you would iterate over the list and use variables to name the
fields. When you process the form, you would iterate over the same list and
extract the values.

Form building:

$foo = array ('priv1', 'priv2', 'priv3' ...);
...
foreach ($foo as $priv) {
        ...
        <input type="checkbox" name="<?php print $priv; ?>"><?php print
$priv; ?>
        ...
}

Form processing:

foreach ($foo as $priv) {
        if (isset($_POST[$priv])) {
                do something here like update the database or build one SQL
statement
        }
}

Instead of using a list when you build foo, you could use a hash.

$foo = array('priv1' => 'Man readable priv 1', 'priv2' => 'Man readable priv
2', 'priv3' => 'Man readable priv 3' ...);
...
foreach (array_keys($foo) as $priv) { 
        ...
        <input type="checkbox" name="<?php print $priv; ?>"><?php print
$foo[$priv]; ?>
        ...
}

Hope this helps.

Giff

-----Original Message-----
From: Ron Piggott (PHP) [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 14, 2006 1:22 PM
To: PHP DB
Subject: [PHP-DB] Web forms

I am creating some web based functions for the staff and volunteers to use.
Access to these functions is designated by those who need it.

I have two tables.  

One table describes the component --- It has a component reference number
column.  

The second table indicates who has access to what --- containing the
component reference number from the component table (described above) and
also the member reference number.  

Essentially if you are logged in your reference number is in a session
variable and using PHP & mySQL the script is checking to see which
components to allow you access to in your menu and only displaying those
menu options.

So far I have been updating this table using phpmyadmin.  I have begun
writing a script to do this in a more smooth fashion.

The script I am writing produces a form in a table.

Column 1 shows the component name.  Column 2 is a check box for the user to
check in if the person whose permissions are being modified should have
access to this component.  I have named the check box the component
reference number --- 1 for example.  There are about 16 components are
growing.  

I am not sure how to check if "$1 = on" indicating the check box was checked
in.  I know you would use an IF ( ) { } statement --- but I want to automate
this so when new components are added in I want have to modify the script
which actually updates who has access to what component.

What I have done so far is selected all the components and started a WHILE
loop --- $i will go from 0 to 15 so I am able to look at each check box to
see if it was selected or not and then I am going to use the INSERT INTO or
DELETE commands to update the table, etc.

How can I find out if $1 and $2 and $3 and ... $15 are "on"?

Ron

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

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

Reply via email to