PHP Classes

Francium PHP 5 Star Rating System: Record star ratings of items in a MySQL with AJAX

Recommend this page to a friend!
  Info   View files Example   Demos   View files View files (13)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 359 All time: 6,907 This week: 114Up
Version License PHP version Categories
fr-star 0.1The PHP License5.2PHP 5, Databases, Content management, A...
Description 

Author

This package can record star ratings of items in a MySQL with AJAX.

It can record in a MySQL database using PDO ratings associated to given items by given users.

The ratings can be added or updated depending on whether the user already rated the item.

The class can also check if the user already rated the item and generate HTML to display the given ratings or the stars to let the user click and set the ratings to be submitted to the server via AJAX requests.

Picture of Subin Siby
  Performance   Level  
Name: Subin Siby is available for providing paid consulting. Contact Subin Siby .
Classes: 5 packages by
Country: India India
Age: 24
All time rank: 46226 in India India
Week rank: 14 Up2 in India India Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Example

<?php
// Generate a user ID for the session only
session_start();
if(!isset(
$_SESSION['user_id'])){
 
$_SESSION['user_id'] = rand(0, 1024);
}
?>
<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="css/Fr.star.css" />
    <script src="http://lab.dev/projects/jquery/core/jquery-latest.js"></script>
    <script src="js/Fr.star.js"></script>
    <script src="js/rate.js"></script>
  </head>
  <body>
    <h1>Francim Star</h1>
    <p>Rating for "index_page" :</p>
    <?php
   
require_once __DIR__ . "/config.php";
   
$star->id = "index_page";
   
    echo
"Rating :";
    echo
$star->getRating("userChoose size-1");
   
    echo
"<p>Your Rating :</p>";
    echo
$star->userRating($_SESSION['user_id']);
    echo
"<p>^- You will have to refresh page to update the above value</p>";
   
    echo
"<h2>Different Sizes</h2>";
   
    echo
"<p>170x30" . $star->getRating("userChoose size-2") . "</p>";
    echo
"<p>115x20" . $star->getRating("userChoose size-3") . "</p>";
    echo
"<p>55x10" . $star->getRating("userChoose size-4") . "</p>";
   
    echo
"<h2>Just Show It !</h2>";
   
    echo
"<p>170x30" . $star->getRating("size-2") . "</p>";
    echo
"<p>115x20" . $star->getRating("size-3") . "</p>";
    echo
"<p>55x10" . $star->getRating("size-4") . "</p>";
   
?>
<!-- NOTICE - http://subinsb.com/francium-star -->
  </body>
</html>


Details

\Fr\Star

A 5 Star Rating System Created With PHP & JavaScript

Documentation & Usage

LICENSED Under Apache License, Version 2.0


  DemoExternal page  
  Files folder image Files  
File Role Description
Files folder imagecss (1 file)
Files folder imageimg (2 files)
Files folder imagejs (2 files)
Accessible without login Plain text file ajax_rate.php Example JavaScript sends AJAX request to this file to submit rating.
Accessible without login Plain text file config.php Conf. The database configuration is in this file.
Plain text file Fr.star.php Class The Class
Accessible without login Plain text file index.php Example An example of the usage of the class.
Accessible without login Plain text file LICENSE Lic. Apache License
Accessible without login Plain text file NOTICE Data Contributors
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file tables.sql Data SQL code to create the table required for the class.

  Files folder image Files  /  css  
File Role Description
  Accessible without login Plain text file Fr.star.css Data Stylesheet to design the star container

  Files folder image Files  /  img  
File Role Description
  Accessible without login Image file Fr-star.png Icon Image of a star
  Accessible without login Plain text file Fr-star.svg Data Image of a star

  Files folder image Files  /  js  
File Role Description
  Accessible without login Plain text file Fr.star.js Data JavaScript library to implement rating system. Contains jQuery plugin too.
  Accessible without login Plain text file rate.js Data An example file that shows the usage of the Fr.star JavaScript plugin.

 Version Control Unique User Downloads Download Rankings  
 100%
Total:359
This week:0
All time:6,907
This week:114Up