Pageviews Plugin (ready)
-
Well, i read somewere that there already is one, and that sucks. But well, i’ve had fun making it, and I just wanted to show it here. It’s xl simple, because you just have to add this within ,,the loop”:
<?php views() ?>
It genrates a new row in the database automatically. Yes i know, you’re all asthonised by this wonderfull plugin …
If i’m online my sever is also, you can find the stuff here and here.
When i’m not online:
<?php
/*
Plugin Name: PPP (Pageviews Per Post)
Plugin URI: https://schot.xs4all.nl/index.php?p=3
Description: Pageview counter for posts, automatic. My site is online, when i'm online ;)
Version: .01b
Author: jmschot
Author URI: https://schot.xs4all.nl
*/function views() {
$count_id = $_GET['p'];
if ($count_id == NULL) {
global $id;
$result = mysql_query("
select *
from wp_count
where count_id='".$id."'");
$r=mysql_fetch_array($result);
echo $r[count] . " pageviews";
return;
}
$result = mysql_query("
select *
from wp_count
where count_id='".$count_id."'");
$r = mysql_fetch_array($result);
if ($r[count] == NULL) {
$create = mysql_query("
insert into wp_count
(count, count_id)".
"VALUES (1, '$count_id')");
$pageviews = "1";
}
else {
$update = mysql_query("
update wp_count
set count = count+1
where count_id='".$count_id."'");
$pageviews = $r[count]+1;
}
echo $pageviews . " pageviews";
}
?>
CREATE TABLE ‘wp_count’ (
‘count’ varchar(255) NOT NULL default ”,
‘count_id’ varchar(25) NOT NULL default ”
) TYPE=MyISAM
Later
- The topic ‘Pageviews Plugin (ready)’ is closed to new replies.