Page 1 of 1

Simple phpwcms counter script here

Posted: Sat 28. Feb 2004, 06:31
by iascoot
Hello

I created a simple phpwcms counter script, it retrieves the vars from phpwcms directly
It just increases each page view, doesnt check to see if user just refreshed the page
Feel free to use the code on your website


To Install you have to use PhpMyAdmin and run this query:

Code: Select all

ALTER TABLE `phpwcms_article` ADD `article_count` INT NOT NULL ;
(if u prepended something onto the table names in setup, change phpwcms_article to that)

Then paste this into a file called count.php (doesnt matter really)

Code: Select all

<?php
/*			This PHP Source was created by Scott Mcleod - 2004©
			Email: iascoot@hotmail.com
			
			Usage: A Simple Counter Script for PHPWCMS (www.phpwcms.de)
			Created:  Saturday, 28 February 2004
			Last Modified:  Saturday, 28 February 2004

*/

// Retrieve The Articles ID
global $content, $sql, $db;
$id = $content["article_id"];
// Retrieve the current count number for the article
	$sql = "SELECT article_count FROM ".DB_PREPEND."phpwcms_article WHERE article_id=$id";
	$result = mysql_query($sql, $db);
	$int = mysql_result($result, 0);
// Update the count number
	$int = $int + 1;
	$sql = "UPDATE ".DB_PREPEND."phpwcms_article SET article_count='$int' WHERE article_id=$id";
	$result = mysql_query($sql, $db);
// Output the result
print $int;
?>

Example Usage:
Page has been Viewed {PHP:count.php} times.
(Page has been Viewed 123 times.)

Posted: Sat 28. Feb 2004, 09:51
by frold
this is why we need a mod forum :lol:

Posted: Sat 28. Feb 2004, 10:54
by Pappnase
hello iascoot

nice hack did you send it also to Oliver? taht he will include it in the next release!?

many greetings to middle earth :wink:

Posted: Sat 28. Feb 2004, 11:27
by iascoot
Hey
Nah i havent submitted it to him yet, I might create another one later on so it doesnt increase if its just a page refresh

ill see what happens tho, anything can happen when you're filled up on energy drinks :P