Tuesday, June 04, 2013
Third last article of mine about page counter widget, now i'd like to give page counter widget based on monthly views. This widget is much alike to the Daily pageviews counter widget that i have published a few days ago, just a little thing makes this widget works a bit different than the daily pageviews counter. It makes use of .txt file for saving data instead of using mysql database, it doesn't realy matter anyway, unless you feel not comfort with some text files that appear on your homepage.

Here are some of the previous page counter widgets that i have published: Individual Page Counter, Total & Unique Page Counter, and Page Counter Based On Weekly Views.

For more page counter widgets, for your information my friends, keep an eye on me, i still have the page views counter based on yearly views and working live online visitor counter to show total online and online visitors on the current page.

Also try this form if you have no idea to unite the widget, like mine on the right side: Creating Table For Counter Widget

How To Create Page, Or Post Counter Widget Based On Monthly Views

If you are going to be confused, don't know how to execute the code i'm gonna give here, as such you need to read my previous post about daily page counter widget. Here i'm not gonna tell you how exactly to execute the code, i will just give it to you, just like that.

I'm going.

<?php
$file = "monthly-stats.txt";
$open = fopen($file, "a+");
$size = filesize($file);
$date = date("D/M/y");
$today = date("M");
if ($file==0) { $counter = 1; fwrite($open, $date."/".$counter);
}
else {
$read = fread($open, $size); $data = explode("/", $read); ftruncate($open, 0);
if($today == $data[1])
{
$counter = $data[3]+1; fwrite($open, $date."/".$counter);
}
else {
$counter = 1; fwrite($open, $date."/".$counter);
}
}
echo "document.write($counter);";
fclose($open);
?>

Here to copy


That's it! Execute the code, take the url, cover it with javascript to call the widget and done, weekly is running. You should be thank me for this, for every page counter widget i gave to you.

Haven't you ever had a look out there? They don't let you own the widget, they only offer you their widget which they set some links inside for they call it credit. Here my friends, i give you just all kind of page counter widget, from each post, daily, monthly, untill yearly page counter, but even so i don't ask for a single link back to you. I heard people love free.. :)

0 comments:

Post a Comment