|
-
Mar 11th, 2006, 08:32 AM
#1
Thread Starter
Fanatic Member
-
Mar 12th, 2006, 12:07 AM
#2
Fanatic Member
Re: how to create the mechanism for rating something!!
That could easily be done in PHP .
-
Mar 12th, 2006, 03:47 AM
#3
Thread Starter
Fanatic Member
Re: how to create the mechanism for rating something!!
can give the idea or the concept?? and the "*" star graphic??
-
Mar 12th, 2006, 06:10 AM
#4
Re: how to create the mechanism for rating something!!
 Originally Posted by kenny_oh
can give the idea or the concept?? and the "*" star graphic??
Its quite simple, something like this.
1. Display dropdown / form with unique location for each one to be rated.
2. User selects andoption and clicks submit.
3. Check users IP has not rated this already. If it has stop the process if not continue.
4. Get the total number of people that have noted and the cumulative note they have mae.
5. Work out the average per person.
6. Work out the level (star) boundaies and then assign as many images as are required.
And thats aboutit I think :
Cheers,
Ryan Jones
-
Mar 12th, 2006, 08:13 AM
#5
Thread Starter
Fanatic Member
Re: how to create the mechanism for rating something!!
hmmm.....i get the idea alr........but how to make the star images on, when user click for rating?
-
Mar 12th, 2006, 08:17 AM
#6
Re: how to create the mechanism for rating something!!
 Originally Posted by kenny_oh
hmmm.....i get the idea alr........but how to make the star images on, when user click for rating?
Probably AJAX, each star has an ID, when clicked it is sent andthen PHP recieves and processed it - it replaced the dropdown menu from my idea 
Cheers,
Ryan Jones
-
Mar 12th, 2006, 10:26 AM
#7
Fanatic Member
Re: how to create the mechanism for rating something!!
AJAX is overkill for something like that..
here is some mockup PHP code that could be used:
//query DB and find the number of ratings, users ect...
switch ($rating) {
case 0:
//no rating
break;
case 1:
//1 star rating
break;
case 2:
//2 star rating
break;
}
-
Mar 12th, 2006, 10:36 AM
#8
Re: how to create the mechanism for rating something!!
 Originally Posted by k1ll3rdr4g0n
AJAX is overkill for something like that..
Actually its perfect for this job, it allows live rating - without needing a form and a page refresh.
Cheers,
Ryan Jones
-
Mar 12th, 2006, 11:19 AM
#9
Re: how to create the mechanism for rating something!!
Indeed, however you should not rely on it so provide a form as well and hide that through JS code. If the browser does not suport JS then the form will be shown.
The general idea for the DB side of it is to store the total number of votes and the total number of vote values. That way you get the average rating from each user.
Example:
A user rates as a 3 - Total votes is 1 and total count is 3, average is 3
another user rates as 1 - Total votes is 2 and count is 4, average is now 2.
Sample PHP/MySQL code for the file that receives the update request (via POST would be the preferred option):
PHP Code:
$id = (int)$_POST['item_id'];
$userRatings = mysql_fetch_assoc(mysql_query(
'SELECT `total_votes`, `total_count` '.
'FROM `user_ratings` WHERE `item_id` = '.$id
));
$votes = $userRatings['total_votes'] + 1;
$count = $userRatings['total_count'] + $_POST['vote_value'];
mysql_query(
'UPDATE `user_ratings` '.
'SET `total_votes` = '.$votes.', `total_count` = '.$count.' '.
'WHERE `item_id` = '.$id
);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|