User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 373,100 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,765 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser:

survey code not working

Join Date: Feb 2008
Posts: 68
Reputation: cmhampton is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 9
cmhampton's Avatar
cmhampton cmhampton is offline Offline
Junior Poster in Training

Re: survey code not working

  #2  
Apr 10th, 2008
The group attribute of cfquery is one of the most unknown and under-appreciated pieces of the entire language. It's so incredibly simple to use it's a wonder more people aren't told about it.

I modified your output to use grouping and it should make your life a little easier (programming life at least, I'm not a messiah )...

Take a look at lines 67-83

  1. <!--- Get ratings --->
  2. <cfquery datasource="PFB" name="RatingsQ">
  3. SELECT *
  4. FROM Ratings, Questions
  5. ORDER BY RatingID, QuestionID
  6. </cfquery>
  7. <!--- Get genders --->
  8. <cfquery datasource="PFB" name="Gender">
  9. SELECT *
  10. FROM Gender
  11. ORDER BY ID
  12. </cfquery>
  13. <!--- Get states --->
  14. <cfquery datasource="PFB" name="State">
  15. SELECT *
  16. FROM State
  17. ORDER BY StateID
  18. </cfquery>
  19. <!--- Get questions2 --->
  20. <cfquery datasource="PFB" name="Questions2">
  21. SELECT *
  22. FROM Questions2
  23. ORDER BY Question_ID
  24. </cfquery>
  25. <!----get ages----->
  26. <cfquery datasource="PFB" name="Age">
  27. SELECT ID, Age
  28. FROM Age
  29. ORDER BY ID
  30. </cfquery>
  31. <html>
  32. <body>
  33. <cfform action="insertnewreview.cfm">
  34. <table>
  35. <tr>
  36. <td>Age:</td>
  37. <td>
  38. <select name="AgeID">
  39. <cfoutput query="Age">
  40. <option value="#ID#">#Age#</option>
  41. </cfoutput>
  42. </select>
  43. </td>
  44. </tr>
  45. <tr>
  46. <td> Gender: </td>
  47. <td>
  48. <select name="Gender">
  49. <cfoutput query="Gender">
  50. <option value="#Gender#">#Gender#</option>
  51. </cfoutput>
  52. </select>
  53. </td>
  54. </tr>
  55. <tr>
  56. <td> State: </td>
  57. <td>
  58. <select name="State">
  59. <cfoutput query="State">
  60. <option value="#State#">#State#</option>
  61. </cfoutput>
  62. </select>
  63. </td>
  64. </tr>
  65.  
  66. <!--- Updated grouping here --->
  67. <cfoutput query="RatingsQ" group="QuestionID">
  68. <tr>
  69. <td>
  70. <br>
  71. <br>
  72. #Question#
  73. </td>
  74. <td>
  75. <cfoutput>
  76. <select name="RatingID">
  77. <option value="#RatingID#">#Rating#</option>
  78. </select>
  79. </cfoutput>
  80.  
  81. </td>
  82. </tr>
  83. </cfoutput>
  84.  
  85. <!--- Changed this cfoutput --->
  86. <cfoutput query="Questions2">
  87. <tr>
  88. <td>#Q#:</td>
  89. <td>
  90. Answer:
  91. <textarea></textarea>
  92. </td>
  93. </tr>
  94. </cfoutput>
  95. <tr>
  96. <td colspan="2" align="center"><input type="submit" value="Insert"></td>
  97. </tr>
  98. </table>
  99. </cfform>
  100. </body>
  101. </html>

I also changed lines 85-94 a little to make the output of the Question2 section a little cleaner.
Reply With Quote  
All times are GMT -4. The time now is 5:10 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC