//This class is required for connecting and accessing database content, without this class my rating class will not work;
include 'database.class.php';
//My rating class
include 'rating.class.php';
//Open a new connection to database
$db = new myDB('root','q1w2e3r4','temp','localhost');
$db->connect();
//Creating a new object of an rating, 3 parameteres:
//1. ($id) ID of page, or just an number unique what identify this page
//2. ($_SERVER['HTTP_REFERER']) The url of curent page
//3. ($vot) Number of stars that i give for this page;
$rate = new Rating($id, $_SERVER['HTTP_REFERER'], $vot);
//This method make a new record evry page refresh
$rate->newhint();
//This method add new rate for this page
$rate->addVot();
/*
Here is an example of use:
So you have 3 pages, if your pages are selected from database by ID replace $id with your id variable. If your page are statical use $id = 1 for first page, $id = 2 for second page and $id = 3 for last page.
For first page the declaration will look like this
$rate = new Rating($id = 1, $_SERVER['HTTP_REFERER'], 5);
$rate->addVot();
here for first page i give 5 stars;
Just copy this code in header of your page and finish :)
To see the result of page rating use this method:
*/
$rate = new Rating('','','');
$rate->showAdminStat();
/* Important for seeing page rating result do not give any parameters for constructor Rating, or feel it empty*/ |