|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
checkboxes
could somebody give me an example regarding how to handle a checkbox in a PHP form.
Like, i want to place couple of checkboxes in one of my form, for example:Studentenrolment,feepaid: when i try to insert a student record into the students table, depending on the condition, i might check both the checkboxes or 1 or leave both empty.But, the value should be stored in the table. how can i do this one.could somebody give me the code. thanks in advance |
|
#2
|
|||
|
|||
|
RE: checkboxes
<input type="checkbox" checked name="whatever" value="whatever">
?? |
|
#3
|
|||
|
|||
|
RE: checkboxes
|
|
#4
|
|||
|
|||
|
RE: checkboxes
I'm trying to insert records into a table.
I've these two checkboxes in a form. Code:
<INPUT type=checkbox name="enrolment<?$stdcount?>" value="1" <? if ($enrolment== 1)echo "checked";?>> <INPUT type=checkbox name="registration<?$stdcount?>" value="1" <? if ($registration== 1)echo "checked";?>> When i check these 2 checkboxes and insert the record into a table, it works pretty fine.IF I LEAVE ONE OR BOTH OF THESE CHECKBOXES UNCHECKED,it produces me an error:"Conversion from string". To avoid this error, i tried to place the following two st's before the sql insert statement. Code:
if ($enrolment==NULL) $enrolment=0; if ($registration==NULL) $registration=0; But, it still gives me the error. I feel that if the checkbox is checked, the value 1 will be inserted into the column or 0. Does'nt it sounds meaningful?? Ps:Stdcount is an array.I guess, there is nothing to do with that. I tried removing spaces and so on, but still, itz the same. So, any idea behind this error?? Thanks everybody. |
|
#5
|
|||
|
|||
|
RE: checkboxes
Try adding in a few print_r()s and echo()s and see if that throws up anything unexpected - that's usually the best way to debug...
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > checkboxes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|