Ok so I'm making a survey for a website and I have a series of questions where the user can rate it from a list of choices and I have these questions in a table in access and the rating options in a table. I want to have the questions display with the options in a dropdown box next to each question, I can't seem to get this to work. Here is my code: <!--- Get ratings ---> <cfquery datasource="PFB" name="RatingsQ"> SELECT * FROM Ratings, Questions ORDER BY RatingID, QuestionID </cfquery> <!--- Get genders ---> <cfquery datasource="PFB" name="Gender"> SELECT * FROM Gender ORDER BY ID </cfquery> <!--- Get states ---> <cfquery datasource="PFB" name="State"> SELECT * FROM State ORDER BY StateID </cfquery> <!--- Get questions2 ---> <cfquery datasource="PFB" name="Questions2"> SELECT * FROM Questions2 ORDER BY Question_ID </cfquery> <!----get ages-----> <cfquery datasource="PFB" name="Age"> SELECT ID, Age FROM Age ORDER BY ID </cfquery> <html> <body> <cfform action="insertnewreview.cfm"> <table> <tr> <td>Age:</td> <td> <select name="AgeID"> <cfoutput query="Age"> <option value="#ID#">#Age#</option></cfoutput> </select> </td> </tr> <tr> <td> Gender: </td> <td> <select name="Gender"> <cfoutput query="Gender"> <option value="#Gender#">#Gender#</option></cfoutput> </select> </td> </tr> <tr> <td> State: </td> <td> <select name="State"> <cfoutput query="State"> <option value="#State#">#State#</option></cfoutput> </select> </td> </tr> <tr> <td><cfoutput query="RatingsQ"><br><br>#Question#</td><td><select name="RatingID"><option value="#RatingID#">#Rating#</option> </select></cfoutput></td></tr> <tr> <td><cfoutput query="Questions2">#Q#:</cfoutput></td> <td>Answer: <textarea></textarea></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="Insert"></td> </tr> </table> </cfform> </body> </html>
What is the probelm? All I can see is that maybe you dont have your <cfoutput query=""> tags in all the right places. Are you getting an error? if so post the error, or just give some more information as to what problem you are having.
No I'm not getting an error at all but I want the select box with the choices to be at the end of each question, instead it makes a select box for each rating and puts that all in one row and the questions are all in one row.
the rating is in the database, it is pulling it from the table in access to display in a dropdown select box on the page.
But what are the ratings? Are they just numbers like 1, 2, 3... ? I will work on it but i think it is a little more complicated to have to pull the ratings from the database if they are just numbers. Its hard because you are trying to pull all the records from two tables. One being the questions and two being the ratings. When you do that the two records will become one record so that every question with have one rating asigned to it.This I think is more of an SQL challenge than CFML. But I will see what I can come up with.
Yeah, I'm thinking part of it might have to do with SQL, I'll try an SQL forum too but I would appreciate any help you can offer. By the way, thank you for responding to my post.
the quick fix is to do this: <!--- Get ratings ---> <cfquery datasource="PFB" name="RatingsQ"> SELECT * FROM Questions ORDER BY QuestionID </cfquery> <cfoutput query="RatingsQ"> <tr> <td>#Question#</td> <td><select name="RatingID"> <option value="Enter the rating ID Number here">Disappointed</option> <option value="Enter the rating ID Number here">Unsatisfied</option> <option value="Enter the rating ID Number here">Neutral</option> <option value="Enter the rating ID Number here">Satisfied</option> <option value="Enter the rating ID Number here">Extremely Satisfied</option> </select> </td> </tr> </cfoutput> Code (markup): That way you output the questions from the database and every question will have a drop down box with the ratings next to it.
It worked, thank you so much. I'm going to be working on it more this weekend so if I have any more questions I'll come here.
Please do, It helps us both to work on each others projects. This Coldfusion forum has been kinda dead lately so its great to see folks coming back to use it. Good luck, Take Care