|
|
Check out this code-Use a cfc which will be the same for you and then change my
query for yours in the .cfm HTHs:
functions.cfc:
<cfcomponent output="yes">
<!--- Next x record function --->
<cffunction name="nextXpage" access="public" returntype="struct" hint="Next x
page function" output="No">
<cfargument name="recordcount" required="Yes" default="0" type="numeric"
hint="The total numbers of records / values">
<cfargument name="page" required="Yes" type="numeric" default="0"
hint="The page number that you are currently on. (for example URL.page)">
<cfargument name="maxrows" required="No" type="numeric" default="10"
hint="The maximum records / values to be displayed per page">
<!--- Define the return structure --->
<cfset var nextXpage = structNew()>
<!--- Calculate how much page are available according to the maxrows
displayed --->
<cfset nextXpage.pagecount = CEILING(arguments.recordcount /
arguments.maxrows)>
<!--- Set the maximum rows to be displayed --->
<cfset nextXpage.maxrows = arguments.maxrows>
<!--- Set the currentpage --->
<cfset nextXpage.currentpage = arguments.page>
<!--- Set the currentpage --->
<cfset nextXpage.recordcount = arguments.recordcount>
<!--- Set the startrow value --->
<cfif arguments.page eq 1>
<cfset nextXpage.startrow = 1>
<cfelse>
<cfset nextXpage.startrow = (arguments.page * arguments.maxrows) -
(arguments.maxrows -1)>
</cfif>
<!--- Define the previous and next values. --->
<!--- Next values --->
<cfif arguments.page neq nextXpage.pagecount>
<cfset nextXpage.next = true>
<cfset nextXpage.nextpage = arguments.page + 1>
<cfelse>
<cfset nextXpage.next = false>
<cfset nextXpage.nextpage = 1>
</cfif>
<!--- Previous values --->
<cfif arguments.page eq 1>
<cfset nextXpage.previous = false>
<cfset nextXpage.previouspage = 1>
<cfelse>
<cfset nextXpage.previous = true>
<cfset nextXpage.previouspage = arguments.page - 1>
</cfif>
<!--- Return the structure --->
<cfreturn nextXpage>
</cffunction>
</cfcomponent>
Then on your output page where you have the info:
.cfm page:
<cfquery name="qrysales" datasource="davanzo_villa.admindb" >
SELECT DISTINCT
clientinfo.Id, clientinfo.RemoteAddress, clientinfo.visit, clientinfo.country
FROM clientinfo
order by clientinfo.Id
</cfquery>
<!--- display hit counter --->
<cfquery name="GetHits">
SELECT * FROM hit_counter
</cfquery>
<cfparam name="URL.page" default="1">
<!--- Determine the navigation parameters --->
<cfset functions = createobject("component","functions")>
<cfset nav = functions.nextXpage(qrysales.recordcount,URL.page,15)>
<table width="792">
<h4>Total Hits: <CFOUTPUT query="GetHits">#hit_count#</cfoutput></h4>
<h4>Total Unique Visitors: <cfoutput>#qrySales.RecordCount#</cfoutput></h4>
</table>
<table width="792">
<tr><td>
<cfoutput>Unique Visitors: #nav.recordcount# (page #nav.currentpage# of
#nav.pagecount#)
<cfif nav.previous>
<a href="hitcount.cfm?page=#nav.previouspage#">Previous</a>
<cfelse>
Previous
</cfif>
<cfif nav.next>
<a href="hitcount.cfm?page=#nav.nextpage#">Next</a>
<cfelse>
Next
</cfif>
[BULLET]
<cfloop From = "1" To = "#nav.pagecount#" index = "pagenumber">
<cfoutput>
<a href="hitcount.cfm?page=#pagenumber#">#pagenumber#</a></cfoutput>
</cfloop>
[/BULLET]
</cfoutput>
</td></tr>
</table>
<table width="792">
<tr>
<td>Date</td>
<td>Visitor Number</td>
<td>Visitor`s IP Address</td>
<td>Visitor`s Country</td>
<td>Path Taken</td>
</tr>
<cfoutput query="qrysales" startrow="#nav.startrow#" maxrows="#nav.maxrows#">
<tr>
<td>#qrySales.visit#</td>
<td>#qrySales.id#</td>
<td>#qrySales.RemoteAddress#</td>
<td><cfif qrysales.country neq ""><a
href="country.cfm?Remote_Addr=#qrysales.RemoteAddress#">#qrySales.country#</a><c
felse><a href="country.cfm?Remote_Addr=#qrysales.RemoteAddress#">Find
country</a></cfif></td>
<td><a href="hitpathdetails.cfm?id=#id#">See path taken</a></td>
</tr>
</cfoutput>
</table>
|
|