PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of 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: 12 years ago
Size: 1,091 bytes


Class file image Download
// 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));