Results 1 to 9 of 9

Thread: how to create the mechanism for rating something!!

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Question how to create the mechanism for rating something!!

    how to create the mechanism like the photo attachs in this post.....to let user rating their view on something like DVD, VCD and etc
    Attached Images Attached Images  

  2. #2
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: how to create the mechanism for rating something!!

    That could easily be done in PHP .
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: how to create the mechanism for rating something!!

    can give the idea or the concept?? and the "*" star graphic??

  4. #4
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: how to create the mechanism for rating something!!

    Quote 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
    My Blog.

    Ryan Jones.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    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?

  6. #6
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: how to create the mechanism for rating something!!

    Quote 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
    My Blog.

    Ryan Jones.

  7. #7
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    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;
    }
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  8. #8
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: how to create the mechanism for rating something!!

    Quote 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
    My Blog.

    Ryan Jones.

  9. #9
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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
  •  



Click Here to Expand Forum to Full Width