I am creating a site where visitors can download files. I would like to record in my database how many time the file has been download.
Can someone help?
Thanks
have the link to the download link to a page that runs an update query first
<cfquery name = "lastDL"...>
select downloadCount, fileLocation from table where fileID = '#url.fileID#'
</cfquery>
<cfset newCount = lastDL.downloadCount + 1>
<cfquery...>
update table set downloadCount = 'newCount' where fileID = '#url.fileID#'
</cfquery>
<cflocation url = "#lastDL.fileLocation#"> <--- assuming the file url is stored in the DB
This will tell you how many download ATTEMPTS there are. Whether or not the download completes or is successfull there's really no way to know.
Hope This Helps!
Ecobb
"Alright Brain, you don't like me, and I don't like you. But lets just do this, and I can get back to killing you with beer." - Homer Simpson
You could also do this in one query. Since you're only returning one row, it shouldn't make that much of a difference, but that all depends on how many files/visitors you have.
<cfquery name="UpdateCount" ...>
update table
set downloadCount = downloadCount + 1
where fileID = '#url.fileID#'
</cfquery>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.