/    Sign up×
Community /Pin to ProfileBookmark

A Question About Page Views

I’m working on a website now but I’m stuck. It’s a tutorial website. I’m trying to get the number of hits one of my tutorials has to display somewhere in my index page. For example: if you viewed the tutorial page, i’d want the counter on my index page to increase with the number of hits the tutorial receives. What would I have to do in order to do this, or where would I have to go to learn it? What would I have to learn? Does somebody have a script for this anywhere?

Thanks for the help.

to post a comment
Full-stack Developer

3 Comments(s)

Copy linkTweet thisAlerts:
@h3r0Jan 01.2008 — I'm sure there's scripts out there, but a simple way to do it (if you know PHP) is to increase an entry in a database for this tutorial id by 1.

This is a function I wrote for my forums:
[code=php]function updateViews($id, $connection) {
$sql = mysql_query("SELECT * FROM forums_posts WHERE id = '".$id."'");
$views = mysql_fetch_array($sql);
$views = $views['views'];
$views = $views + 1;
$sql = mysql_query("UPDATE forums_posts SET views = '".$views."' WHERE id =".$id." LIMIT 1;");
}[/code]
Copy linkTweet thisAlerts:
@ahhgeaauthorJan 22.2008 — Thanks a lot for the help. I forgot my password and couldn't reply. I've spent the last month learning php and this makes a lot of sense now.
Copy linkTweet thisAlerts:
@h3r0Jan 22.2008 — Your welcome ?
×

Success!

Help @ahhgea 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 4.29,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...