|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
checkboxes again
hi,
i had posted this query earlier but maybe i wasnt too clear. basically i have three checkboxes on my form: GROUP TYPE : <INPUT type="checkbox" name="groupID" value="1" <? echo $gflag;?>>STUDENT <INPUT type="checkbox" name="groupID" value="2" <? echo $gflag2;?>>PROFESSOR <INPUT type="checkbox" name="groupID" value="3" <? echo $gflag3;?>>VISITING FACULTY Now the value which are 1,2 or 3 are the values which are in my database table too ...example 1 for student. i used <? if ($idType==1){ $flag="checked";} else if ($idType==2){ $flag2="checked";} else if ($idType==3){ $flag3="checked";} else {$flag="";} ?> to pre-check the values in my form depending on whats in the database table which works just great. my problem is that if the user adds or edits a record i want to insert into the table which is called users_in_groups the userID and the new groupID whcih i get from the checkbox...there will obviously be a multiple insert of rows if the user checks 2 checkboxes. i wnt to do if ($update) { foreach..... well...i dotn know what to put in there to update...can soemone pls pls help me....i am really stuck |
|
#2
|
|||
|
|||
|
RE: checkboxes again
why don't you try using radio buttons?
< input type = "radio" name = "groupName"> |
|
#3
|
|||
|
|||
|
RE: checkboxes again
hi,
i cant use radio button since a person can belong to more than one group.... |
|
#4
|
|||
|
|||
|
RE: checkboxes again
firstly you need to rename 'groupID' to 'groupID[]' for each one.
Then foreach($_POST['groupID'] as $id) { mysql("UPDATE table...."); } something like that, just remember when updating the table, to use $id not $groupID |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > checkboxes again |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|