?
Solved

Survey Results Quick Question

Posted on 2003-03-06
4
Medium Priority
?
163 Views
Last Modified: 2013-12-24
I have the following Survey with the followign DB:

Questions Table is TblSurveyQuestions: QuestionID, Survey Question
Answers Table is TblSurveyAnswers: AnswerID, ChoiceText, Question, ChoiceOrder

Now I have a query on the page that displays the info as such

<cfquery name="Survey" datasource="#DB#">
SELECT TblSurveyQuestions.QuestionID, TblSurveyQuestions.SurveyQuestion,
TblSurveyAnswers.AnswerID, TblSurveyAnswers.Question, TblSurveyAnswers.ChoiceText, TblSurveyAnswers.ChoiceOrder
FROM TblSurveyQuestions, TblSurveyAnswers
WHERE TblSurveyQuestions.QuestionID=TblSurveyAnswers.Question
ORDER By ChoiceOrder
</cfquery>

<cfform name="survey" method="post" action="SurveyDetails.cfm">
<cfinput name="Answer" type="radio" value="#Survey.AnswerID#" required="yes" message="Please Select a Choice">

<input name="submit" type="submit" class="SurveyButton" value="Continue">
</cfform>

I just want to output the results on how many times a choice has been selected. So i will have it on a separate page.

So all i wanna do is output the following for example:
Question:Hey how are you
AnswerID:5
AnswerID:10
AnswerID:15
AnswerID:50

On the details page here is teh query that I have:

<!--- Querying the News Details Page Based on the Form Value Passed --->
<cfquery name="SurveyDetails" datasource="#DB#">
SELECT * FROM TblSurveyAnswers WHERE ID = #FORM.Answer#
</cfquery>

Thanks a gain for all your help,
ISM
0
Comment
Question by:ISM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Expert Comment

by:danrosenthal
ID: 8085704
try this...

SELECT AnswerID, count(1) AS num_answers
FROM TblSurveyAnswers
WHERE Question = #questionID#
GROUP BY AnswerID

0
 
LVL 10

Expert Comment

by:substand
ID: 8085750
<cfquery name="Survey" datasource="#DB#">
SELECT TblSurveyQuestions.QuestionID, TblSurveyQuestions.SurveyQuestion
FROM TblSurveyQuestions, TblSurveyAnswers
WHERE TblSurveyQuestions.QuestionID=TblSurveyAnswers.Question
ORDER By TblSurveyQuestions.QuestionID
</cfquery>

<cfoutput query="survey">
<cfquery name="answers" datasource="#DB#">
select TblSurveyAnswers.AnswerID, TblSurveyAnswers.Question, TblSurveyAnswers.ChoiceText, TblSurveyAnswers.ChoiceOrder
where TblSurveyAnswers.Question=#questioID#;
ORDER By ChoiceOrder
</cfquery>
#surveyQuestion#<br>
<cfloop query=answers>
#answers.answerID# #answers.ChoiceText#<br>
</cfloop>
</cfoutput>
-----------------------------------------------------------
that will output the questions and answers.  but where are your recorded responses?  you cant get anywwhere without them.
0
 

Author Comment

by:ISM
ID: 8087264
Ok, I have tried both ways and I keep getting number 11 all the time whatever I do and I am passing the question ID as a hidden form variable becauase I don't have it that query as you see from my code above. There are two sepaerate tables one for questins and one for answers.

If I can onyl output the results like that:

Quetion 1 is pulling form the questions table an dhave four choices in the answers table:

How are you doing today:

Answers and results:
I am doing fine (ChoiceText in the AnswerTable): 45 times slected or answered
Not too bad (ChoiceText in the AnswerTable): 20 times selected and so on
Alright(ChoiceText in the AnswerTable):
Cool(ChoiceText in the AnswerTable):

<cfquery name="SurveyDetails" datasource="#Application.Datasource#">
SELECT AnswerID, count(1) AS num_answers
FROM TblSurveyAnswers
WHERE Question = #Form.question#
GROUP BY AnswerID
</cfquery>

<html>
<head>
<title><cfoutput>#Application.Title#</cfoutput></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="Styles.css" rel="stylesheet" type="text/css">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="493" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="493" height="444" valign="middle" background="images/NewsBg.gif">
      <blockquote class="NewsDetailTitle">&nbsp;</blockquote>
      <blockquote class="Copy">
        <p>&nbsp;</p>
        <br>
        <table width="425" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="42" valign="top">&nbsp;</td>
            <td width="383" valign="top"><p class="NewsDetailTitle">
               <cfoutput>#SurveyDetails.AnswerID#</cfoutput><br>
                <br>
              </p>
              <p align="right">
                <input name="button" type="button" class="SearchButton" onClick="javascript:window.close()" value="Close">
              </p></td>
          </tr>
        </table>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
      </blockquote></td>
  </tr>
</table>
</body>
</html>

Again, thank you all for youe help,
ISM
0
 
LVL 10

Accepted Solution

by:
substand earned 75 total points
ID: 8090095
ok make this your queries:

<cfquery name="SurveyDetails" datasource="#Application.Datasource#">
SELECT unique AnswerID, ChoiceText, ChoiceOrder
FROM TblSurveyAnswers
WHERE Question = #Form.question#
order by choiceorder
</cfquery>
<cfoutput query="surveydetails">
#printYourQuestionherefromtheQuestionQuery#
<cfquery name="numtimes" datasource="#application.datasource#">
select count(*) as theCount from TblSurveyAnswers
where answerID=#answerID#;
</cfquery>
#choiceText#: #numtimes.theCount#<br>
</cfoutput>
0

Featured Post

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question