title: How to calculate average on star rating system?
body: <p>I am developing a star rating system with 1-5 stars.
  In my database I am saving them like this:</p>
  
  <pre><code>$stars_1 = 1;
  $stars_2 = 6;
  $stars_3 = 3;
  $stars_4 = 11;
  $stars_5 = 22;
  
  $total_votes = 43
  </code></pre>
  
  <p>When a user votes using for example 3 stars I update stars_3 with 1 and total_votes with 1.
  Then I need to calculate the average rating (stars).</p>
  
  <p>I do it like this right now but I is not working (result seems wrong):</p>
  
  <pre><code>(($stars_1 + $stars_2 + $stars_3 + $stars_4 + $stars_4) / $total_votes);
  </code></pre>