Php-mysql Course

This is a script to add a Rating System (with 5, 7 or 10 Stars) to rate images, articles, videos, games, or any element in pages of your web site.
This Stars Rating Script uses Ajax technology, with JavaScript and PHP (with OOP), it can be included in any page (".html", or ".php"), but the server must run PHP.
The rating data can be saved in TXT files on the server, SQLite database, 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.

• To Download it, click: Ajax-PHP Rating Stars Script.

- The script has 4 versions:


- Details about Installation and Settings you'll find in a "readme.html" file, in the archive with the script.
• It is indicated to put the script in the root directory of you website. If you copy it into a subfolder, see the instructions below.


In the archive with this script there is another zip archive (rating_stars_script_set_time.zip) with files that can be used to set various times in which the user can rate the items. For more details, see the instructions from the Other settings category in the readme.html page.

Demo, version with 5 stars and 5 numbers to rate

- Move the cursor over the stars, and click to rate the following images:
Test Rating Script
Test Rate Script.
Rate Dolphin
Star Rating Script.

• If the rating data are saved in MySQL or SQLite 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).
Example:
SELECT `item`, (`totalrate` / `nrrates`) AS `rank` FROM `rtgitems` ORDER BY (`totalrate` / `nrrates`) DESC LIMIT 10

• 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:
obajx.open("post", '/ratingfiles/ratings.php', true);

With this line of code (to use the absolute path to the "ratings.php" file):
obajx.open("post", 'http://'+ document.domain +'/ratingfiles/ratings.php', true);

If the "ratingfiles" folder is not in Root, delete the beginning "/":
obajx.open("post", 'ratingfiles/ratings.php', true);

Or, add the sub-folder name, with '/' from root::
obajx.open("post", '/subfolder/ratingfiles/ratings.php', true);

- Also, be sure to have in each page the correct path to the "ratings.css", and "ratings.js" files, included in the HTML code.

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which HTML element can be used to embed a SWF flash content?
<object> <div> <script>
<object type="application/x-shockwave-flash" data="file.swf" width="500" height="250">
 <param name="src" value="file.swf" />
 Your browser not support SWF.
</object>
Which CSS pseudo-class adds a style to an input form field that has keyboard input focus?
:active :focus :hover
input:focus {
  background-color: #88fe88;
}
Click on the instruction which converts a JSON string into a JavaScript object.
JSON.stringify(javascript_object) object.toString() JSON.parse(json_string)
var jsnstr = '{"url": "http://coursesweb.net/", "title": "Web Development Courses"}';
var obj = JSON.parse(jsnstr);
alert(obj.url);
Indicate the PHP function which can be used to create or write a file on server.
fopen() file_put_contents() file_get_contents()
if (file_put_contents("file.txt", "content")) echo "The file was created";
else echo "The file can not be created";
Ajax-PHP Rating Stars Script

Last accessed pages

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (142308)
  2. Get and Modify content of an Iframe (32367)
  3. $_GET, $_POST and $_REQUEST Variables (33884)
  4. Ajax-PHP Chat Script (49508)
  5. JavaScript Course - Free lessons (31647)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (311)
  2. The Mastery of Love (48)
  3. CSS cursor property - Custom Cursors (36)
  4. Read Excel file data in PHP - PhpExcelReader (35)
  5. PHP-MySQL free course, online tutorials PHP MySQL code (31)