ISM
asked on
Survey Results Quick Question
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.Questio nID, TblSurveyQuestions.SurveyQ uestion,
TblSurveyAnswers.AnswerID, TblSurveyAnswers.Question, TblSurveyAnswers.ChoiceTex t, TblSurveyAnswers.ChoiceOrd er
FROM TblSurveyQuestions, TblSurveyAnswers
WHERE TblSurveyQuestions.Questio nID=TblSur veyAnswers .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
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.Questio
TblSurveyAnswers.AnswerID,
FROM TblSurveyQuestions, TblSurveyAnswers
WHERE TblSurveyQuestions.Questio
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
<cfquery name="Survey" datasource="#DB#">
SELECT TblSurveyQuestions.Questio nID, TblSurveyQuestions.SurveyQ uestion
FROM TblSurveyQuestions, TblSurveyAnswers
WHERE TblSurveyQuestions.Questio nID=TblSur veyAnswers .Question
ORDER By TblSurveyQuestions.Questio nID
</cfquery>
<cfoutput query="survey">
<cfquery name="answers" datasource="#DB#">
select TblSurveyAnswers.AnswerID, TblSurveyAnswers.Question, TblSurveyAnswers.ChoiceTex t, TblSurveyAnswers.ChoiceOrd er
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.
SELECT TblSurveyQuestions.Questio
FROM TblSurveyQuestions, TblSurveyAnswers
WHERE TblSurveyQuestions.Questio
ORDER By TblSurveyQuestions.Questio
</cfquery>
<cfoutput query="survey">
<cfquery name="answers" datasource="#DB#">
select TblSurveyAnswers.AnswerID,
where TblSurveyAnswers.Question=
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.
ASKER
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.D atasource# ">
SELECT AnswerID, count(1) AS num_answers
FROM TblSurveyAnswers
WHERE Question = #Form.question#
GROUP BY AnswerID
</cfquery>
<html>
<head>
<title><cfoutput>#Applicat ion.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">&n bsp;</bloc kquote>
<blockquote class="Copy">
<p> </p>
<br>
<table width="425" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="42" valign="top"> </td>
<td width="383" valign="top"><p class="NewsDetailTitle">
<cfoutput>#SurveyDetails.A nswerID#</ 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> </p>
<p> </p>
<p> </p>
</blockquote></td>
</tr>
</table>
</body>
</html>
Again, thank you all for youe help,
ISM
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.D
SELECT AnswerID, count(1) AS num_answers
FROM TblSurveyAnswers
WHERE Question = #Form.question#
GROUP BY AnswerID
</cfquery>
<html>
<head>
<title><cfoutput>#Applicat
<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.
<blockquote class="NewsDetailTitle">&n
<blockquote class="Copy">
<p> </p>
<br>
<table width="425" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="42" valign="top"> </td>
<td width="383" valign="top"><p class="NewsDetailTitle">
<cfoutput>#SurveyDetails.A
<br>
</p>
<p align="right">
<input name="button" type="button" class="SearchButton" onClick="javascript:window
</p></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
</blockquote></td>
</tr>
</table>
</body>
</html>
Again, thank you all for youe help,
ISM
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT AnswerID, count(1) AS num_answers
FROM TblSurveyAnswers
WHERE Question = #questionID#
GROUP BY AnswerID