Skip to main content
Inspiring
November 7, 2008
Question

Confused......

  • November 7, 2008
  • 1 reply
  • 207 views
Ok, I have a page that counts up the number of members in a certain group,
and then puts them into an array. The problem I'm having is that if I delete
members from the database, the webpage reflects the change, say from 40 members
down to 7, but the array is still counting a total of 40 members.

For adding to the array I have:


<cfset classList=arraynew(2)>
<cfset classListLoop="A,B,C,D,E,U">
<cfset bigLoopCount=0>
<cfif #url.e# eq 1>
<cfset bigLoopCount=2>
<cfelse>
<cfset bigLoopCount=1>
</cfif>
<cfloop from="1" to="#bigLoopCount#" index="j">
<cfset classLoopCount=1>
<cfloop list="#classListLoop#" delimiters="," index="i">
<cfset classList[#j#][#classLoopCount#][1]=#i#>
<!--- send to udf to count each rating occurance and assign
to variable --->
<cfinvoke component="components.ov_rating" method="rating"
returnvariable="result">
<cfinvokeargument name="tid" value="#url.tid#">
<cfinvokeargument name="dbfield" value="#j#">
<cfinvokeargument name="rating" value="#i#">
</cfinvoke>
<cfset classList[#j#][#classLoopCount#][2]=#result#>
<cfset classLoopCount=classLoopCount+1>
</cfloop>
<!--- send array to CFC to calculate the total number of
members, assign to item 7 of array --->
<cfinvoke component="components.addAll" method="add" returnvariable="totalMembers">
<cfinvokeargument name="members" value="#classList#">
</cfinvoke>
<cfset ArrayAppend(classList[#j#],#totalMembers#)>

<!--- Send array and regTotal to UDF to determine tournament
classification --->
<cfinvoke component="components.class" method="determine" returnvariable="classification">
<cfinvokeargument name="fencers" value="#classList#">
<cfinvokeargument name="fencerNumber" value="#classList[7]#">
</cfinvoke>
<cfset ArrayAppend(classList[#j#],#classification#)>
</cfloop>

CFC ov_rating is:
<cfcomponent displayname="ov_rating" hint="Groups ratings by class">
<cffunction name="rating" hint="Counts number of ratings and type" returntype="numeric"
output="no">
<cfargument name="tid" required="yes" type="numeric">
<cfargument name="dbfield" required="yes" type="numeric">
<cfargument name="rating" required="yes" type="string">
<cfset var result=0>
<!--- <cfset var db_field=0> --->

<cfswitch expression="#arguments.dbfield#">
<cfcase value="1">
<cfset db_field="e_foil_rating">
</cfcase>
<cfcase value="2">
<cfset db_field="e_epee_rating">
</cfcase>
</cfswitch>


<cfquery name="CountRating" datasource="SalleBoise">
select count(<cfqueryparam cfsqltype="cf_sql_varchar" value="#db_field#">)
as total
from TournEvent
where e_tid=<cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.tid#">
and #db_field#=<cfqueryparam cfsqltype="cf_sql_char" value="#arguments.rating#">
</cfquery>

<cfset result=#CountRating.total#>
<cfreturn result>

</cffunction>
</cfcomponent>

CFC addAll is:
<cfcomponent displayname="addAll" hint="Adds all members of the events">
<cffunction name="add" hint="Counts number of members" returntype="numeric"
output="no">
<cfargument name="members" required="yes" type="array">

<cfset var regTotal=0>
<cfloop from="1" to="6" index="i">
<cfset regAdd=arguments.members[1][#i#][2]>
<cfset regTotal=regTotal + regAdd>
</cfloop>

<cfreturn #regTotal#>
</cffunction>
</cfcomponent>

CFC class is:
<cfcomponent displayname="class" hint="Determines the classification of the
tournament">
<cffunction name="determine" hint="Counts number of ratings and type" returntype="string"
output="no">
<cfargument name="fencers" required="yes" type="array">
<cfargument name="fencerNumber" required="yes" type="numeric">

<cfset var result="Unrated">

<cfswitch expression="#arguments.fencerNumber#">
<!--- For 6 fencers, no rating --->
<cfcase value="6">
<cfset result="E1">
</cfcase>
<!--- 15 fencers, 2 C's, or 2 D's, or 2 E's minimum --->
<cfcase value="15">
<cfif (#arguments.fencers[3][2]# gte 2) and (#arguments.fencers[4][2]# gte
2) and (#arguments.fencers[5][2]# gte 2)>
<cfset result="C1">
<cfelseif (#arguments.fencers[2][2]# gte 2) and (#arguments.fencers[3][2]#
gte 2) and (#arguments.fencers[4][2]# gte 2)>
<cfset result="B1">
<cfelseif (#arguments.fencers[1][2]# gte 2) and (#arguments.fencers[2][2]#
gte 2) and (#arguments.fencers[3][2]# gte 2)>
<cfset result="A1">
<!--- 15 fencers, no rating --->
<cfelse>
<cfset result="D1">
</cfif>
</cfcase>
<!--- 25 fencers, 4 D's or 4 E's minimum --->
<cfcase value="25">
<cfif (#arguments.fencers[4][2]# gte 4) and (#arguments.fencers[5][2]# gte
4)>
<cfset result="C2">
<cfelseif (#arguments.fencers[2][2]# gte 2) and (#arguments.fencers[3][2]#
gte 2) and (#arguments.fencers[4][2]# gte 2)>
<cfset result="B2">
<cfelseif (#arguments.fencers[1][2]# gte 2) and (#arguments.fencers[2][2]#
gte 2) and (#arguments.fencers[3][2]# gte 2)>
<cfset result="A2">
</cfif>
</cfcase>
<cfcase value="64">
<cfif (#arguments.fencers[4][2]# gte 24) and (#arguments.fencers[5][2]# gte
12)>
<cfset result="C3">
<cfelseif (#arguments.fencers[3][2]# gte 24) and (#arguments.fencers[4][2]#
gte 12)>
<cfset result="B3">
<cfelseif (#arguments.fencers[2][2]# gte 24) and (#arguments.fencers[3][2]#
gte 12)>
<cfset result="A3">
<cfelse>
<cfset result="A4">
</cfif>
</cfcase>
</cfswitch>

<cfreturn result>

</cffunction>
</cfcomponent>


    This topic has been closed for replies.

    1 reply

    Inspiring
    November 7, 2008
    which of your arrays are you talking about? that's a lot of code to try
    and get one's head around... please be more specific.



    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/