|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
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
|
|||
|
|||
|
Hi,
I am working on coldfusion. I have three tables as follow: user, skill, user_skill After a user login, there are several checkbox showned. The user will put some checks within some skills checkbox. For example, coldfusion, dreamweave, phb, fireworks, I try to insert these skills into user_skill table. I created the insert query as: <cfquery datasource="datasource_name"> insert into user_skill values(#form.userid#, #form.skillid#); </cfquerry> However, I got error message such as : Syntax error (comma) in query expression 'skillid like cf,html,phb,fw,fla'. It seems it treated the bunch values (with comas) as a whole field. Does anyone know how to insert it as following Userid Skillid 1 cf 1 html 1 Phb 1 Fw 1 fla 2 fw Does anyone know how to do? Thanks |
|
#2
|
|||
|
|||
|
Checkboxes are treated as a list of values. So if you check 3 boxes the target page will have a list like:
form.skillid = "cf,html,php" You can loop over the list of values and insert each one individually. <cfloop index="thisSkill" list="#form.skillid#"> <cfquery datasource="datasource_name"> insert into user_skill values(#form.userid#, #thisSkill#); </cfquerry> </cfloop> |
|
#3
|
|||
|
|||
|
thank you
Thanks so much . I got it now. Thanks
|
|
#4
|
|||
|
|||
|
I forgot that I modified your code little bit to make it work.
I have to put single quote around this skill in values |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > insert checkbox data value |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|