• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Dynamic Counter

New Here ,
Apr 30, 2007 Apr 30, 2007

Copy link to clipboard

Copied

I have a results page that lists different records. Each record has a link to the detail page. Can I and how do I track how many times a record has been viewed on the detail page? I would say I'm between a novice and average when it comes to CF, so please speak slowly : )
TOPICS
Advanced techniques

Views

215

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 01, 2007 May 01, 2007

Copy link to clipboard

Copied

LATEST
you will likely need to add a field to your db table, say call it
"viewcount", datatype: integer, default value: 0.

then on the page that displays the record details add an update query to
increment the viewcount value by 1:

<cfquery name="updatecounter" datasource="yourdsnhere">
UPDATE mytable SET viewcount = viewcount + 1 WHERE recordid =
<cfqueryparam cfsqltype="cf_sql_integer" value="#URL.recordid#">
</cfquery>

NOTE: i have assumed you are passing the recordid to the details page as
a url variable. change the above query as necessary.
--

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation