Survey code not working

Discussion in 'Programming' started by krazykrisi, Apr 7, 2008.

  1. #1
    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>
     
    krazykrisi, Apr 7, 2008 IP
  2. unitedlocalbands

    unitedlocalbands Well-Known Member

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #2
    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.
     
    unitedlocalbands, Apr 7, 2008 IP
  3. krazykrisi

    krazykrisi Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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.
     
    krazykrisi, Apr 7, 2008 IP
  4. unitedlocalbands

    unitedlocalbands Well-Known Member

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #4
    Do you have to dynamically create the rating?
     
    unitedlocalbands, Apr 7, 2008 IP
  5. krazykrisi

    krazykrisi Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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.
     
    krazykrisi, Apr 8, 2008 IP
  6. unitedlocalbands

    unitedlocalbands Well-Known Member

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #6
    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. :)
     
    unitedlocalbands, Apr 8, 2008 IP
  7. krazykrisi

    krazykrisi Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    They are Disappointed, Unsatisfied, Neutral, Satisfied, and Extremely Satisfied.
     
    krazykrisi, Apr 8, 2008 IP
  8. krazykrisi

    krazykrisi Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    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.
     
    krazykrisi, Apr 8, 2008 IP
  9. unitedlocalbands

    unitedlocalbands Well-Known Member

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #9
    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.
     
    unitedlocalbands, Apr 9, 2008 IP
  10. krazykrisi

    krazykrisi Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Ok, I'll give it a try. Thank you.
     
    krazykrisi, Apr 10, 2008 IP
  11. krazykrisi

    krazykrisi Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    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.
     
    krazykrisi, Apr 10, 2008 IP
  12. unitedlocalbands

    unitedlocalbands Well-Known Member

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #12
    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
     
    unitedlocalbands, Apr 10, 2008 IP