PHP Classes

Star rating package: Process and show rating stars given by the user

Recommend this page to a friend!
  Info   View files Example   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 60%Total: 1,571 This week: 1All time: 2,506 This week: 560Up
Version License PHP version Categories
rating-package 1.0.0GNU General Publi...5.1PHP 5, Databases, Content management, A...
Description 

Author

This class can be used to process and display rating stars given by the user to site content.

It can generate HTML and Javascript to let the user rate site content.

When the user rates content an AJAX request using Iframe is sent to the server to avoid page reloading.

The class updates the content ratings stored in a MySQL database and renders updated content ratings as response to the AJAX request.

Picture of akash
Name: akash <contact>
Classes: 3 packages by
Country: India India
Age: ???
All time rank: 96357 in India India
Week rank: 411 Up26 in India India Up
Innovation award
Innovation award
Nominee: 1x

Winner: 1x

Recommendations

What is the best PHP star rating class?
I would like PHP star rating script

Example

<?php
$itemID
= $_POST['itemId'];
$rating = $_POST['rating'];
require_once(
'RatingManager.php');

$status = RatingManager::saveRating($itemID, $rating);

if (
$status === false) {
    exit;
}
?>
<html>
<head>
<script type="text/javascript">
function bodyLoaded() {
    if (!parent.document.getElementById('itemRating_<?php print $itemID; ?>')) {
        return;
    }
    parent.document.getElementById('itemRating_<?php print $itemID; ?>').innerHTML = document.getElementById('bodyContainer').innerHTML;
    document.getElementById('bodyContainer').innerHTML = '';
}
</script>

</head>
<body onLoad="return bodyLoaded();" id="bodyContainer">
<?php
RatingManager
::drawItemRating($itemID, false);
?>
</body>
</html>


  Files folder image Files  
File Role Description
Files folder imageimages (3 files)
Accessible without login Plain text file javascript.php Aux. includes javascript to the code and downloads the images required
Plain text file RatingManager.php Class PHP class which handles all the code and the requests
Accessible without login Plain text file set-item-rating.php Example Page used to save the rating for item
Accessible without login Plain text file sql.txt Data Rating table used for the rating system. Create this table in any database and rename the table name. Make the respective changes in the RatingManager.php constants also
Accessible without login Plain text file test.php Example Example page, run this page to test the functionality

  Files folder image Files  /  images  
File Role Description
  Accessible without login Image file star1.gif Icon Star image
  Accessible without login Image file star2.gif Icon Star image
  Accessible without login Image file star3.gif Icon Star image

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,571
This week:1
All time:2,506
This week:560Up
 User Ratings  
 
 All time
Utility:87%StarStarStarStarStar
Consistency:81%StarStarStarStarStar
Documentation:-
Examples:87%StarStarStarStarStar
Tests:-
Videos:-
Overall:60%StarStarStarStar
Rank:1138