Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page counter

Status
Not open for further replies.

calista

Programmer
Jan 24, 2001
545
US
I have an intranet whose primary purpose is to provide on-line access to project documentation. I have a database of documents that I query based on user selections. The user is presented with a list of document titles and descriptions, and the title is a link to the document itself. I would like to be able to count the number of "hits" each document gets. I can count vistors to the page that lists the documents easily enough, but how do I record which link the user clicked on? Sounds simple, but I'm not quite sure what to do. Thanks! Calista :-X
Jedi Knight,
Champion of the Force
 
I would create a retrieval template, that recorded the "hit" on the document, then used cfcontent tags to give the document to the user. For example, if each document has a unique id:

Link
<a href=&quot;retrieve_doc.cfm?documents_id=#documents_id#&quot;>#file_name#</a>

Retrieve Template
<cfquery name=&quot;count_hit&quot; datasource=&quot;#ds#&quot;>
UPDATE documents
SET total_viewed = total_viewed + 1
WHERE documents_id = #url.documents_id#
</cfquery>
<cfquery name=&quot;file_details&quot; datasource=&quot;#ds#&quot;>
SELECT file_name
FROM documents
WHERE documents_id = #url.documents_id#
</cfquery>

<cfheader name=&quot;Content-disposition&quot; value=&quot;attachment; filename=#file_details.file_name#&quot;>
<cfcontent type=&quot;application/unknown&quot; file=&quot;#path_to_files#\#file_name#&quot; deletefile=&quot;No&quot;>


Of course, using this method might cause the browser prompt to save the file when the filetype is usually opened in the browser window, but at least you have counted it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top