Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Kai Ming Choi  >  Count Class  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example file
Class: Count Class
Keep track of site visitors in a MySQL database
Author: By
Last change:
Date: 2010-07-16 22:51
Size: 1,091 bytes
 

Contents

Class file image Download
<pre><?
// Count Class Example

include "count.class.php";

//Connect MySQL Database
$link mysql_connect("127.0.0.1""root""mingming") or die("Fail to connect database");
mysql_select_db("test");

//call count class
//for visit count
$count = new Count(3600512"Asia/Taipei"8);

//for online count
//$count = new Online(3600, 512, 180, "Asia/Taipei", 8);

//Setup Table(s), for first time only
//var_dump($count->install());

//record for specific type, allow repeat count in the this page
$count->record("1"true);
$count->record("1"true);
$count->record("1"true);
$count->record("2"true);
$count->record("2"true);

//show the record, interval 3hours
var_dump($count->read(3*3600));

//show the max./min., interval 3hours
var_dump($count->analyseMaxMin(3*3600));
 
//find out the average count in each hour, needs at least a day record
var_dump($count->analyseAverage(864003600));

//find out the average online in each weekday, needs at least a week record
var_dump($count->analyseAverage(60480086400));

mysql_close($link);
?>