Ajax-PHP Rating Stars Script
This is a script to add a Rating System (with 5 or 10 Stars) to rate images, articles, videos, games, or any element in pages of your web site.
The rating data can be saved in TXT files on the server, or in a MySQL database (using PDO).
The rated item, the number of the day, and the user (name or IP) are saved on the server, also in cookies, so, the user /visitor can rate again the next day.
You can use the script to add rating system to one or more elements in a web page.
If you have a register /login script in your web site, you can set this Rating Script to allow only the logged users to rate. By default, all the visitors can rate an element once to 24 hours.
• The script has 4 versions: Five stars with 10 numbers to vote (1, 2, 3, 4, ... 10), Five stars with 5 numbers to rate (1, 2, 3, 4, 5), Seven rating stars, and Ten rating stars.
It has been tested successfully on Mozilla Firefox, Internet Explorer, Google Chrome and Opera.
- Details about Installation and Settings you'll find in a "readme.html" file, in the archive with the script.
• To Download it, click: .
If you want to set another time when the user can vote again, for example over 2 days, next week, or you want the user to can vote an item a single time only, use the PHP files from this archive:
- Then, replace the "class.rating.php", "create_tables.php", and "ratings.php" with the files from this archive.
- See the comments in "ratings.php". Then access the "create_tables.php" to create the tables in MySQL database.
With these php files, data can be stored only in MySQL database.
Demo (move the cursor over the stars, and click to rate the following images):
• If the rating data are saved in MySQL database:
To create a list which ranks the score of multiple voted items, based on highest rating, perform a MySQL Select in the "rtgitems" table. This table stores the voted items (in "item" column), points (in "totalrate" column), and number of votes (in "nrrates" column).
• If you want to use this Rating Script in pages that are in different folders, and the current settings not works, open the "ratings.js" file (in "ratingfiles" directory), and replace this code (line 115):
With this line of code (to use the absolute path to the "ratings.php" file):
Or, if the "ratingfiles" folder is not in Root, replace with this code (relative path from current folder):
- Also, be sure to have in each page the correct path to the "ratings.css", and "ratings.js" files, included in the <head> area of the HTML code.