ORDER BY agent_areas.agent_area_id DESC, agents.agent_name and this is the code for the output:

#areaName#

#agentName#

in the second cfoutput i want to put something like: Do this do this hope that makes sense i've tried putting COUNT within my query: eg: select count(agentName) as total from tableName where bla bla bla, but it wont work....because it will only return the total no of records, not the ones within the nested cfoutput also tried sql count on group by, but that gets rid of some results that we need to return... any ideas ? thanks shafiq :sK [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => Shaffer [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 4 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) -->

#areaName#

#agentName# Do this
alternative select * from agent_areas select * from agents SELECT * FROM getAllAgents WHERE Area = #AreaID# #agentName No Agents for this Area!! [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => zoeski80 [ip] => zoe@webraven.co [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 5 [islastshown] => 1 [isfirstshown] => [attachments] => [allattachments] => ) --> recordcount of a nested cfoutput .... - Coldfusion - Advanced Techniques

recordcount of a nested cfoutput .... - Coldfusion - Advanced Techniques

<cfoutput query='sqlGetAgents' group='areaName'> <h4>#areaName#</h4> <cfoutput group='agentID'> <p><strong>#agentName#</strong></p> </cfoutput> </cfoutput> how do i get the recordcount of the number of items within the nested cfoutput ? thanks...

  1. #1

    Default recordcount of a nested cfoutput ....

    <cfoutput query='sqlGetAgents' group='areaName'> <h4>#areaName#</h4>
    <cfoutput group='agentID'> <p><strong>#agentName#</strong></p> </cfoutput>
    </cfoutput> how do i get the recordcount of the number of items within the
    nested cfoutput ? thanks

    Shaffer Guest

  2. #2

    Default Re: recordcount of a nested cfoutput ....

    You would have to do some counting yourself. There is no RecordCount for the
    nested grouped output, because it is really all the same query, CF is just
    doing a little formatting for you. You are going to have to set a variable for
    the "areaName" and see if it is different than the previous row...if it is,
    start a counter for the inner loop until that areaName changes again.



    blewis Guest

  3. #3

    Default Re: recordcount of a nested cfoutput ....

    Well, if that's what you really want in the cfoutput then:

    Select distinct areaname, agentname from sometable order by areaname

    would give you the same results, and RecordCount would be equal to the
    nested number of items.

    OldCFer Guest

  4. #4

    Default Re: recordcount of a nested cfoutput ....

    ok, Let me see if i can explain a little better: We have a query that gets
    countrys and agents that belong to that country...we want to display the
    country and the details for each agent that belongs to that country.....we need
    to know the number of agents that belong to each country (hope you with me so
    far) the sql i have for this is as follows: (btw, using mysql 4.0) <cfquery
    name='sqlGetAgents' datasource='#Application.dsn#'> SELECT
    agent_areas.agent_area_id, agents.agent_id AS agentID, agents.agent_name AS
    agentName, agents.agent_address AS agentAddress, agents.agent_telephone_no AS
    agentTelNo, agents.agent_fax_no AS agentFaxNo, agents.agent_email_address AS
    agentEmail, agent_areas.agent_area_name AS areaName FROM agents, agent_areas,
    agent_regions, agent_divisions, product_divisions WHERE
    agent_regions.agent_region_id = #url.id# AND agent_areas.agent_area_id =
    agents.agent_area_id AND agent_regions.agent_region_id =
    agent_areas.agent_region_id AND agents.agent_id = agent_divisions.agent_id AND
    product_divisions.product_division_id = agent_divisions.product_division_id AND
    agent_divisions.product_division_id = #url.did# <!--- did = Division ID Passed
    from product_detail.cfm ---> ORDER BY agent_areas.agent_area_id DESC,
    agents.agent_name </cfquery> and this is the code for the output:
    <cfoutput query='sqlGetAgents' group='areaName'> <h4>#areaName#</h4> <cfoutput
    group='agentID'> <p><strong>#agentName#</strong></p> </cfoutput> </cfoutput>
    in the second cfoutput i want to put something like: <cfif noOfAgents GT 1>Do
    this</cfif> <cfif agent.currentRow EQ noOfAgents - 1>do this </cfif> hope that
    makes sense i've tried putting COUNT within my query: eg: select
    count(agentName) as total from tableName where bla bla bla, but it wont
    work....because it will only return the total no of records, not the ones
    within the nested cfoutput also tried sql count on group by, but that gets rid
    of some results that we need to return... any ideas ? thanks shafiq :sK

    Shaffer Guest

  5. #5

    Default Re: recordcount of a nested cfoutput ....

    Hi Shaffer

    Attached code shows the count that you need to add to your existing code. Have
    also shown an alternate method which will produce the same outcome.

    I haven't looked too closely at your query but will it retrieve the areas that
    have no agents in them?? It doesn't look like it as you aren't using OUTER
    JOINS at all. When joining to the agents table you'd need to do a LEFT OUTER
    JOIN to also retrieve the areas that don't have any agents setup.
    (NB. alternate code will not have a proble with areas that have not agents
    setup)

    Hope this helps.

    Zoe

    <!--- loop over query grouped by area name --->
    <cfoutput query="sqlGetAgents" group="areaName">

    <h4>#areaName#</h4>

    <!--- set/reset agent Counter ---->
    <CFSET agentCount = 0>

    <cfoutput group="agentID">
    <CFSET agentCount = agentCount + 1>
    #agentName#
    </cfoutput>

    <!--- agentCount will be the recordCount for the area --->
    <CFIF agentCount GT 1>
    Do this
    </CFIF>

    </cfoutput>


    alternative

    <!--- get all areas --->
    <CFQUERY NAME="getAreas">
    select * from agent_areas
    </CFQUERY>

    <!--- get all agents --->
    <CFQUERY NAME="getAllAgents">
    select * from agents
    </CFQUERY>


    <!--- loop over areas --->
    <CFLOOP QUERY="getAreas">

    <!--- get agents for the current area - using QoQ --->
    <CFQUERY NAME="getAreaAgents">
    SELECT *
    FROM getAllAgents
    WHERE Area = #AreaID#
    </CFQUERY>

    <CFIF getAreaAgents.RecordCount GT 0>
    <!---- loop over agents for the area --->
    <CFLOOP QUERY="getAreaAgents">
    #agentName
    </CFLOOP>
    <CFELSE>
    No Agents for this Area!!
    </CFIF>

    </CFLOOP>

    zoeski80 Guest

Similar Threads

  1. RecordCount Issues
    By supportcenter in forum Coldfusion Database Access
    Replies: 6
    Last Post: November 9th, 01:05 PM
  2. recordCount property
    By fu-meng in forum Coldfusion - Getting Started
    Replies: 2
    Last Post: May 16th, 03:48 PM
  3. Getting a recordcount
    By Andy Levy in forum PHP Development
    Replies: 3
    Last Post: October 29th, 08:55 AM
  4. recordcount -1
    By middletree in forum ASP
    Replies: 8
    Last Post: October 16th, 02:06 PM
  5. Why does the RecordCount property always = -1
    By George Mizzell in forum Macromedia Dreamweaver
    Replies: 2
    Last Post: July 13th, 01:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •