PHP Classes

AJAX Rating Counter: AJAX based star rating system

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (12)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 58%Total: 7,751 All time: 228 This week: 148Up
Version License PHP version Categories
ajaxratingcounter 1.0.0Free for non-comm...4Content management, AJAX
Description 

Author

This package can be used to implement a star rating system that uses AJAX to update the average rate without reloading the rate page after a user has voted.

It can display the current average rating between 1 to 10 using star icon images.

A new rating submitted by an user is sent to the server using an AJAX request. The server returns the updated rating average and the star icon images change to the new rating value.

Picture of Er. Rochak Chauhan
  Performance   Level  
Name: Er. Rochak Chauhan <contact>
Classes: 54 packages by
Country: India India
Innovation award
Innovation award
Nominee: 15x

Winner: 3x

Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Ajax Rating Counter</title>
   
        <script src="javascript.js" type="text/javascript"></script>
        <style type="text/css">

        .ratingText {
            font-family: verdana;
            font-weight: bold;
            font-size: 16px;
            color: #FFFFFF;
            background-color: #FF0000;
            width: 135px;
        }
        </style>
    </head>
<body>
<?php
   
/**
     * Example file
     *
     */
   
    // file/ database to be accessed for rating of 'id'
   
$file1 = file_get_contents('rating.txt');
   
$filearray1 = explode(',', $file1);
   
$rating1 = array_sum($filearray1)/count($filearray1);
   
   
   
// file/ database to be accessed for rating of 'newid'
   
$file2 = file_get_contents('rating2.txt');
   
$filearray2 = explode(',', $file2);
   
$rating2 = array_sum($filearray2)/count($filearray2);
   
   
    require_once(
'AjaxRatingCounter.inc.php');
   
$ajaxRatingCounter = new AjaxRatingCounter();

   
$ajaxRatingCounter->addStars($rating1, 'id');
   
$ajaxRatingCounter->addStars($rating2, 'newid');
    echo
$ajaxRatingCounter->displayStars();
?>

</body></html>


Screenshots  
  • screenshot.jpg
  Files folder image Files  
File Role Description
Accessible without login Plain text file ajax.php Aux. Back end file
Plain text file AjaxRatingCounter.inc.php Class Main Class
Accessible without login Image file even1.jpg Icon Image
Accessible without login Plain text file example.php Example Example file
Accessible without login Plain text file javascript.js Data javascript File
Accessible without login Image file odd1.jpg Photo Image
Accessible without login Plain text file rating.txt Data rating counter dbase
Accessible without login Plain text file rating2.txt Data rating file
Accessible without login Image file _even1.jpg Icon Image
Accessible without login Image file _odd1.jpg Icon image
Accessible without login Image file __even1.jpg Icon image
Accessible without login Image file __odd1.jpg Icon Image

 Version Control Unique User Downloads Download Rankings  
 0%
Total:7,751
This week:0
All time:228
This week:148Up
 User Ratings  
 
 All time
Utility:85%StarStarStarStarStar
Consistency:78%StarStarStarStar
Documentation:-
Examples:79%StarStarStarStar
Tests:-
Videos:-
Overall:58%StarStarStar
Rank:1524