Hit counters for all the individual records of one table in the database.

I wanted to make a hit counter for my site which could count all the hits for each individual record of one table in the database. I searched the Internet but could not find what I wanted. Then I asked George Petrov of www.udzone.com and he explained how it could be done. Thanks George.

Hit counters for all the individual records of one table in the database.
I wanted to make a hit counter for my site which could count all the hits for each individual record of one table in the database. I searched the Internet but could not find what I wanted. Then I asked George Petrov of www.udzone.com and he explained how it could be done. Thanks George.


I am using Ultradev 4 with MS Access.
1) First of all you need an extra field in your database table. Make this field as a Number field instead of a Text field.



2) You will need a detail page to make this work. If you don't know how to make a detail page please check Ultradev help topics.
3) Now open your detail page and select Command (Stored Procedure) from the Data Bindings panel.



4) You will get this command window, first select your connection and then select Update under the Type, drop down menu.



5) Type this in SQL box:
UPDATE Articles
SET fHits = fHits + 1
WHERE fArticleID = ParamArticleID

type this in Name box:
ParamArticleID
type this in Run-time Value box:
Request.QueryString("fArticleID")
You need to pass this value fArticleID when you call to the detail page. Your URL will look something like this when you will call to the detail page. (e.g: http://www.yourdomain.com/detail.asp?fArticleID=4)



6) That's all!

Written by Babar Mubarak




Comments

Problems...

June 25, 2001 by rubs eguan

Hi guys, I've tryed to implement this into my site... I try to account how many times a user logs into my site and store in a field. I've followed all the steps you speak above very carefully, but althoug no error message is displayed when cliking the submit button, the field is not updated in anyway... I wonder if there is any special feature to take into account...

Thank you.rubs

I have the same problem..no update in field

July 2, 2001 by Joost Meij

I'm using an SQL server database and made added a number field with 0 as standard value. I also get no error message..but no updat is done and i cant find anything wrong with the command! Is it different for an SQL database?

Besides Request.QueryString

July 3, 2001 by Neafevoc Marindale

I'm wondering if there was an alternative method besides using Request.QueryString("stringHere")?

I was able to get Request.Form to work with it.

But I want to Request("SomethingElse") if possible that's not done through Form nor QueryString.  Like just setup up some value on the page just to trigger the counter once.

The problem I found is that if I don't have any QueryString on my URL, the page will error out :(

very easy.

September 24, 2001 by syr prize
thx for tip. very easy + runs good
See all 17 Comments

You must me logged in to write a comment.