Hi guys,
I have a page where I want to display a list of agents within our database, to the right hand side of those agents names I want to have a total number of clients they have registered. I know this should be nothing complicated but for some reason I can't get it to work.
I have this so far:
This code gives me my list of agents:
<cfquery name="rs_viewagent" datasource="mydatasource">
SELECT *
FROM dbo.users_table
WHERE access_level = 'agent'
ORDER BY company ASC
</cfquery>
This should give me my totals:
<cfquery name="rs_clientsregistered" datasource="mydatasource">
SELECT *
FROM dbo.clients_table
WHERE agentID = '#rs_viewagent.username#'
</cfquery>
I then have a standard <cfoutput query="rs_viewagent"> to dump the results down the page, and a record count to display the stats. #rs_clientsregistered.RecordCount#.
When I view this page I get the agents display fine and I get the recordcount from the first person in the query "rs_viewagent" repeated down the page. I know this has something to do with the fact that I need to tell it which person in the db I want stats for for, and that this will have to be dynamicly generated from the repeat region but how. I have searched for ways to link to queryies and so on but cannot find anything that will give the right result. Am I missing something Simple?
Thanks
Rob
I have a page where I want to display a list of agents within our database, to the right hand side of those agents names I want to have a total number of clients they have registered. I know this should be nothing complicated but for some reason I can't get it to work.
I have this so far:
This code gives me my list of agents:
<cfquery name="rs_viewagent" datasource="mydatasource">
SELECT *
FROM dbo.users_table
WHERE access_level = 'agent'
ORDER BY company ASC
</cfquery>
This should give me my totals:
<cfquery name="rs_clientsregistered" datasource="mydatasource">
SELECT *
FROM dbo.clients_table
WHERE agentID = '#rs_viewagent.username#'
</cfquery>
I then have a standard <cfoutput query="rs_viewagent"> to dump the results down the page, and a record count to display the stats. #rs_clientsregistered.RecordCount#.
When I view this page I get the agents display fine and I get the recordcount from the first person in the query "rs_viewagent" repeated down the page. I know this has something to do with the fact that I need to tell it which person in the db I want stats for for, and that this will have to be dynamicly generated from the repeat region but how. I have searched for ways to link to queryies and so on but cannot find anything that will give the right result. Am I missing something Simple?
Thanks
Rob