Results 1 to 3 of 3

Thread: Rating System

  1. #1

    Thread Starter
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734

    Rating System

    I want to create a rating system, simple enough, but I wonder how to average the votes, then determine what is equals in stars. Sorta of like Vbulliten. How does it calculate, and hold the votes?

  2. #2
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    well this is how I did it.

    PHP Code:
    if ($num_row == '1') {
        while(
    $row=$db->fetch($voter)){
            
    $num $row["votes"];
            
    $total $row["total"];
        }
        
    $num intval($num $total);
        echo 
    "<b>User Rated at: </b><img src=\"images/".$num "stars.gif\">";

    } else {
        echo 
    "<b>User Rated at:</b> <img src=\"images/0stars.gif\">";

    I keep a total and a votes column. that way you can get an average for the votes. so like this forums does it counts the votes (1-5) and then it adds one to the total. so if 2 people voted and they both voted 5 the votes will = 10 and the total will = 2, so then you get 10 / 2 and a vote average of 5 and then you can display the correct number of stars.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  3. #3

    Thread Starter
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734
    Thanks thats what I needed

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