Mark,
This form of CFOUTPUT (<CFOUTPUT QUERY = "Results">) is basically a LOOP.
It executes once for every row in the QUERY's result-set.
The easiest solution is probably just to shift the "No Votes Have Been
Cast" outside of that loop. Maybe something like this:
<CFIF Totals.TotalVotes EQ 0>
No Votes Have Been Cast.
<CFELSE>
<CFOUTPUT QUERY="Results">
<CFSET Percent = Round((Votes / Totals.TotalVotes) * 100)>
<B><i>#Answer#:</i></B> #Percent#%
</CFOUTPUT>
</CFIF>
Does that work? Hope so.
Lee (Bjork) Borkman
http://bjork.net ColdFusion Tags by Bjork
-----Original Message-----
From: Mark Smeets [mailto:[EMAIL PROTECTED]]
....
Let's say no one votes, I want to display a message that reads "No one has
voted in this poll" or something to that extent, now, I have this all in 1
cfoutput tag, and under that I've basically dumped all my "stuff".
The problem is that, I get the same message (no one has voted in this poll)
appearing for the number of vote choices. So if you can choose 3 options to
vote for, you'll get the message 3 times.
Is there a way to only print that message once within that output query?
I'll include the query and the code for the hell of it.
<CFQUERY DATASOURCE = "Stranger" NAME = "Totals">
SELECT Q.Question, SUM(A.Votes) AS TotalVotes
FROM Question Q INNER JOIN Answer A ON Q.QuestionID = A.QuestionID
WHERE Q.QuestionID = #QuestionID#
GROUP BY Q.Question
</CFQUERY>
<CFOUTPUT QUERY = "Results">
<!--- Set the percent of total votes for each answer. --->
<tr>
<td colspan="3"><CFIF Totals.TotalVotes EQ 0>No Votes Have Been
Cast.<CFELSE><CFSET Percent = Round((Votes / Totals.TotalVotes) *
100)><B><i>#Answer#:</i></B> #Percent#%</td>
</tr>
<!--- Dispaly the percentage of votes in a graph format. The width of the
bar image is equal to the percentage.--->
<tr>
<td colspan="3">
<IMG ALIGN = "top" SRC = "vote_undecided.gif" WIDTH = "#Percent#" HEIGHT =
"5">
</cfif>
</CFOUTPUT>
</p>
</td>
</tr>
IMPORTANT NOTICE:
This e-mail and any attachment to it is intended only to be read or used by
the named addressee. It is confidential and may contain legally privileged
information. No confidentiality or privilege is waived or lost by any
mistaken transmission to you. If you receive this e-mail in error, please
immediately delete it from your system and notify the sender. You must not
disclose, copy or use any part of this e-mail if you are not the intended
recipient. The RTA is not responsible for any unauthorised alterations to
this e-mail or attachment to it.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists