1 Reply Latest reply on May 1, 2007 12:12 AM by Newsgroup_User

    Dynamic Counter

      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 : )
        • 1. Re: Dynamic Counter
          Level 7
          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#">

          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