I'm getting confused.
My HTML form processes a number of these elements:
name="perms[<?PHP echo $menu_one_ID ?>][<?PHP echo $menu_two_ID ?>]" value="<?PHP echo $permission ?>"
$menu_one_ID is an integer
$menu_two_ID is an integer
$permission is an integer (from 0 to 4)
So it gives arrays like these:
perms[1][0] = 3;
perms[2][0] = 2;
perms[2][1] = 3;
perms[2][2] = 4;
perms[3][0] = 0;
etc.
The arrays can differ, as the numbers are generated from a database.
I want the value in between the first brackets to be entered in my database in the field menu_one_ID, and the value in between the second pair of brackets in the field menu_two_ID.
So, i'd do this:
while(list($key,$val) = each($perms)) {
if (is_array($key)) {
while(list($key2,$val2) = each($key)) {
$sql = "INSERT INTO admin_perms (
admin_ID,
menu_one_ID,
menu_two_ID,
perm
) VALUES (
" . $this->userID . ",
" . $key . ",
" . $key2 . ",
" . $val2 . "
)";
$result = mysql_query($sql);
if (!$result) {
return FALSE;
}
}
}
}
It doesn't work. I'm confused with the list/each thing. Can anyone help me?