Jump to content


page views for individual pages


5 replies to this topic

#1 Tupling

    Young Padawan

  • Members
  • Pip
  • 2 posts

Posted 29 December 2008 - 01:10 PM

I have been looking for some time now to find something to steer me in the right direction.

I am looking to code a simple page view counter. Similar to the one used on Pixel2life for how many times a tutorial as been viewed...

Maybe i have overlooked it and didn't realize it but could someone steer me in the right direction please...

Thanks! :angrylooking:

#2 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 29 December 2008 - 01:18 PM

I use mysql...

this is what I do, this is just a basic overview you may have to change some things

<?php

$tid = mysql_escape_string($_GET['tid']); // tutorial id

$sql = mysql_query("SELECT * FROM `tutorials` WHERE `id` = '$tid'") or die (mysql_error());

$fetch = mysql_fetch_array($sql);

$num = 1;

$views = $fetch['views'];

$add = $num + $views;

mysql_query("UPDATE `tutorials` SET `views` = '$add' WHERE `id` = '$tid'") or die (mysql_error());

// etc etc

?>

Again, that is a basic overview of what I use. Someone else may have something else

#3 Pr0oF

    Young Padawan

  • Members
  • Pip
  • 19 posts

Posted 29 December 2008 - 01:31 PM

It can be managed even with one line.
mysql_query("update `table` set `field` = (`field`+1) where `id` = '$id'");


#4 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 29 December 2008 - 03:12 PM

View PostPr0oF, on Dec 29 2008, 01:31 PM, said:

It can be managed even with one line.
mysql_query("update `table` set `field` = (`field`+1) where `id` = '$id'");

what he said lol

#5 Pr0oF

    Young Padawan

  • Members
  • Pip
  • 19 posts

Posted 29 December 2008 - 04:49 PM

View Postbigdfbc2008, on Dec 29 2008, 10:12 PM, said:

what he said lol
m? something wrong?

#6 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 04 January 2009 - 12:11 AM

na nothing wrong, just never knew it could be done that way :(





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users