Location: PHPKode > scripts > Count Script > example.php
// Count Class Example

include "count.class.php";

//Connect MySQL Database
$link = mysql_connect("", "root", "mingming") or die("Fail to connect database");

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

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

//Setup Table(s), for first time only

//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

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

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

Return current item: Count Script