John,
Instead of updating a cell in the table each time why no try inserting a row
into a table each time the page is viewed. If you throw a query into each
page that looks something like the one below you will be able to easily
query the table to get the hit count and you will also have the ability to
search via a date range which will give you more accurate figures. Don't
worry about the table getting too big as it only has a small amount of data
so it should still be manageable.
Query:
<cfquery name="updatehits" datasource="my_datasource">
INSERT INTO
hitcounter(
page,
hit_date
)VALUES(
<cfqueryparam value="#CGI.script_name#?#CGI.query_string#"
/>,
<cfqueryparam value="#now()#" />
)
SET hit_count = hit_count + 1
</cfquery>
Hope that helps
-Simon Free
On Wed, May 28, 2008 at 10:33 PM, John Barrett <[EMAIL PROTECTED]> wrote:
> Hi,
> I am trying to make a counter, which writes the input to a db. This works
> fine on single pages (index.cfm, etc.). However, I am confused on how to get
> this to work on a actionpage, which queries the db for 100s of articles. The
> app in question is at http://cfhawaii.com/nutrition_media/youngheart.cfm It
> is basically a master detail page set up. If you go to the page there
> are 8 links to articles which links to
> http://cfhawaii.com/nutrition_media/complete_article_page55.cfm?article_id=1
> where the article is by id. The code below counter all views,a nd I am
> trying to figure out how to just count the view per id??
>
> Thanks so much,
> John
>
>
> <!--- Counter Code--->
> <cfquery name="gethits" datasource="my_datasource">
> SELECT hit_count
> FROM hitcounter
> </cfquery>
>
> <cfif gethits.recordcount IS 0>
> <cfquery name="inserthit" datasource="my_datasource">
> INSERT INTO hitcounter ( hit_count) VALUES (1)
> </cfquery>
> <cfelse>
> <center><b>No. of viewers: </b><cfoutput query="gethits"><font
> size="+2">#hit_count#</font></cfoutput> </center>
> </cfif>
>
> <cfquery name="updatehits" datasource="my_datasource">
> UPDATE hitcounter
> SET hit_count = hit_count + 1
> </cfquery>t by 1 --->
> UPDATE hitcounter
> SET hit_count = hit_count + 1
> </cfquery>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k
Archive:
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3669
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15