/    Sign up×
Community /Pin to ProfileBookmark

PHP – Page Counter

Hi

I am trying to create a page counter in PHP.

Table structure:

[CODE]
Table Name: tbl_counter
Column Name:total_views
Column Datatype: integer[/CODE]

I am using the following SQL query on the page.

[CODE]
UPDATE tbl_counter SET total_views=total_views+1[/CODE]

I know its weird but, sometimes the counter increases twice instead of 1, any idea why?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@scragarAug 10.2008 — It could be a simple lack of a response to a request, method of avoiding this is to simply log the users IP, if they view the page again too soon ignore the increment, sure it's slower, but it avoids your error.
×

Success!

Help @phantom007 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...