Ajax Rating System: Create Simple Ajax Rating System using jQuery AJAX and PHP.
Simply programmed, CSS based stylish Ajax rating system which you can use any where to put a stylish jquery effect based rating system.
Table Structure:
CREATE TABLE `ajax_ratings` (
`id` int(11) NOT NULL auto_increment,
`image_id` int(11) NOT NULL default '0',
`rating` int(11) NOT NULL default '0',
`users_ip` varchar(200) NOT NULL default '',
PRIMARY KEY (`id`)
)
Javascript Code:
$(document).ready(function(){
$('#loader').hide();
$('#inner').children().click(function(){
var a = $(this).attr("id");
$.post("rating.php?value="+a, {
}, function(response){
$('#inner').fadeOut();
$('#inner').html(unescape(response));
$('#inner').fadeIn();
setTimeout("hideMesg();", 2000);
});
});
});
function hideMesg(){
$('.rating_message').fadeOut();
$.post("rating.php?show=1", {
}, function(response){
$('#inner').html(unescape(response));
$('#inner').fadeIn('slow');
});
}
PHP Code
include("dbcon.php");
$users_ip = $_SERVER['REMOTE_ADDR'];
if($_REQUEST['value'])
{
$id = $_REQUEST['value'];
$result = mysql_query("select users_ip from ratings where users_ip='$users_ip'");
$num = mysql_num_rows($result);
if($num==0)
{
$query = "insert into ratings (rating,users_ip) values ('$id','$users_ip')";
mysql_query( $query);
$result=mysql_query("select sum(rating) as rating from ratings");
$row=mysql_fetch_array($result);
$rating=$row['rating'];
$quer = mysql_query("select rating from ratings");
$all_result = mysql_fetch_assoc($quer);
$rows_num = mysql_num_rows($quer);
if($rows_num > 0){
$get_rating = floor($rating/$rows_num);
$rem = 5 - $get_rating;
}
}
}
72 to “Ajax Rating System: Create Simple Ajax Rating System using jQuery AJAX and PHP.”
Post comment

Categories
- AJAX (28)
- Announcement (3)
- Blogging Tips (1)
- Codeigniter (16)
- CSS (14)
- Facebook (8)
- Freelance Tips (1)
- How-To (2)
- Joomla (1)
- JQuery (51)
- Miscellaneous (3)
- Mootools (1)
- MySQL (3)
- PHP (57)
- SEO (2)
- Technology (6)
- Tutorials (17)
- Twitter (2)
- Web Design (26)
- Web Development (58)
- WordPress (3)
Popular post
- 46 Highly Responsive Admin Templates for Your Websites
- $50 PayPal Cash & 5 Premium PHP Wall Script Prizes #Giveaway
- PHP Wall Script Clone with Real Time Features __ January 2013 Release __
- Things you should know if you are a Blogger
- Top 10 Must Have Qualities of a Freelance Web Developer
- Fundamental Factors for Mobile Compatible eCommerce Hosting
- Facebook Wall Script New Version in September 2012
Recommend


[...] system or Voting system is very common in web sites. Voting can be about your site or blog or some other thing just to get [...]
[...] tutorial in Rating System series is here for you. It is a stylish and animated rating system I created many Ajax based Rating [...]
[...] system or Voting system is very common in web sites. Voting can be about your site or blog or some other thing just to get [...]
[...] system or Voting system is very common in web sites. Voting can be about your site or blog or some other thing just to get [...]
[...] tutorial in Rating System series is here for you. It is a stylish and animated rating system I created many Ajax based Rating [...]
[...] tutorial in Rating System series is here for you. It is a stylish and animated rating system I created many Ajax based Rating [...]
[...] system or Voting system is very common in web sites. Voting can be about your site or blog or some other thing just to get [...]
[...] system or Voting system is very common in web sites. Voting can be about your site or blog or some other thing just to get [...]
[...] method or Voting method is really widespread in internet internet sites. Voting can be about your internet site or weblog [...]
[...] system or Voting system is very common in web sites. Voting can be about your site or blog or some other thing just to get [...]
Dude Update table name “ratings” to “ajax_ratings”. Because in you MySQL query you are creating a table named “ajax_ratings”.
hey can u provide me this rating system in codeigniter.???
thanx in advance…..
hey can u customize dis module in codeigniter??plz do it….
hi Codie, I will write a tutorial in Codeigniter later in the next month.
I get errors in index.php and i do not know how to fix it
hi, i’ve been trying to incorporate this script into my site where i want to show products with this ratings attached..i’ve tried sincerely but i seem to be getting everything wrong please what do i do
hi, please how do i call up both product and rating from mysql dynamically.
This rating system is very nice. A note to others who try it: you will need to update the index.php and rating.php scripts:
change the reference to table name ratings to ajax_ratings. And in some places you will need to change the field name ratings to rating.
Otherwise, works great, really is nice and simple!
Hi ZeeShaN I want to ask a question to you. This script is working perfect bu I want to do this. How can İ write to database my image id that I voted? Can you help me for that?
i want star image in place of box how can i achieve it can you help me i don’t know about jquery and java script
Hi! This site is a big help for me since I am creating a website. Thanks to your tutorials. However, this particular demo tutorial doesn’t work anymore. Please do fix this one. Thanks a lot again.
an error -
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\starrating\index.php on line 41
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\starrating\index.php on line 46
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\starrating\index.php on line 47
please chek then upload full working with source file …………………..