Parsing unchecked checkboxes into array
Posted: Wed Jun 26, 2002 1:13 am
Something that i have been working on for a while:
I have a number of checkboxes that I want the results recorded into an array. The problem is that I want the unchecked results to be recorded as well. What I have at the moment is the following:
It only reads in checked boxes:
Code to display & read in checkboxes:
WHILE ($Get_Roles_Row = mssql_fetch_array($Get_Roles_Result)) {
echo "<input type=checkbox name=Role_Checkbox[]> $Get_Roles_Row[Role_ID]<br>";
}
Code to insert results into database:
for ($i=0;$i < count($Role_Checkbox); $i++)
{
//Insert into database statement here;
echo "$Role_Checkbox[$i], $i, <br>,"; // testing to confirm insert
}
What I am trying to do is create a page for server operators to describe what roles their server serves.
ie
role table is (where the information is gathered from:
role_id role
1 mail server
2 file server
etc....
Then I want to insert these results into a Server_Roles table, which takes the form of:
server_id role_id
1 1
1 2
2 5
2 8
etc.....
Any ideas? Should I be doing this another way?
Thanks for any help..............
I have a number of checkboxes that I want the results recorded into an array. The problem is that I want the unchecked results to be recorded as well. What I have at the moment is the following:
It only reads in checked boxes:
Code to display & read in checkboxes:
WHILE ($Get_Roles_Row = mssql_fetch_array($Get_Roles_Result)) {
echo "<input type=checkbox name=Role_Checkbox[]> $Get_Roles_Row[Role_ID]<br>";
}
Code to insert results into database:
for ($i=0;$i < count($Role_Checkbox); $i++)
{
//Insert into database statement here;
echo "$Role_Checkbox[$i], $i, <br>,"; // testing to confirm insert
}
What I am trying to do is create a page for server operators to describe what roles their server serves.
ie
role table is (where the information is gathered from:
role_id role
1 mail server
2 file server
etc....
Then I want to insert these results into a Server_Roles table, which takes the form of:
server_id role_id
1 1
1 2
2 5
2 8
etc.....
Any ideas? Should I be doing this another way?
Thanks for any help..............