Hi,
This is the most simple thing I want to do, but my brain seems to have fallen asleep!
What I want to do is when i add a user to a DB, i also want to set in another table the ‘permissions’ each user has by use of check boxes. If it is checked, then add it, if not, don’t.
What happens is that it inserts the 1st checked value, and then ignores the rest. So if i only selected one at a time, it’d add all i want, but if i check 2 or more, it only inserts the one the appears 1st.
the code i’ve done is:
[code=php]
$userid = htmlentities($_POST[‘userid’]);
$tooladd = htmlentities($_POST[‘tooladd’]);
$tooldelete = htmlentities($_POST[‘tooldelete’]);
$toolmodify = htmlentities($_POST[‘toolmodify’]);
$toolview = htmlentities($_POST[‘toolview’]);
$tooladd2 = ‘INSERT INTO dbtools.tblpermissions (userid, permiss) VALUES (“‘.$userid.'”, “tooladd”);’;
$tooldelete2 = ‘INSERT INTO dbtools.tblpermissions (userid, permiss) VALUES (“‘.$userid.'”, “tooldelete”);’;
$toolmodify2 = ‘INSERT INTO dbtools.tblpermissions (userid, permiss) VALUES (“‘.$userid.'”, “toolmodify”);’;
$toolview2 = ‘INSERT INTO dbtools.tblpermissions (userid, permiss) VALUES (“‘.$userid.'”, “toolview”);’;
if ($tooladd == “on”) {
$tooladd3 = mysql_query($tooladd2);
}
if ($tooldelete == “on”) {
$tooldelete3 = mysql_query($tooldelete2);
}
if ($toolmodify == “on”) {
$toolmodify3 = mysql_query($toolmodify2);
}
if ($toolview == “on”) {
$toolview3 = mysql_query($toolview2);
}
I’m sure all it needs is a loop or something similar but my head ain’t workin!
Thanks in advance,
Rich