title: Creating 5 Star Rating System With PHP , MySQL ,Jquery And Ajax
body: <p>I've downloaded this tutorial <a href="http://megarush.net/5-star-rating-system-with-php-mysql-jquery-and-ajax/" rel="noreferrer">http://megarush.net/5-star-rating-system-with-php-mysql-jquery-and-ajax/</a> but I'm getting these errors:</p>
  
  <p>Notice: Undefined variable: rat in C:\xampp\htdocs\rating\rating.php on line 37</p>
  
  <p>Notice: Undefined variable: v in C:\xampp\htdocs\rating\rating.php on line 41   </p>
  
  <pre><code>&lt;?php
  include("settings.php");
  connect();
  $ids=array(1,2,3);
  ?&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script src="jquery.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;link rel="stylesheet" href="rating.css" /&gt;
  &lt;script type="text/javascript" src="rating.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
   &lt;?php
   for($i=0;$i&lt;count($ids);$i++)
  {
      $rating_tableName     = 'ratings';
   $id=$ids[$i];
   $q="SELECT total_votes, total_value FROM $rating_tableName WHERE id=$id";
  $r=mysql_query($q);
  if(!$r) echo mysql_error();
  while($row=mysql_fetch_array($r))
  {
  $v=$row['total_votes'];
  $tv=$row['total_value'];
  $rat=$tv/$v;
  
  }
  
  
  
  $j=$i+1;
  $id=$ids[$i];
  echo'&lt;div class="product"&gt;
         Rate Item '.$j.'
          &lt;div id="rating_'.$id.'" class="ratings"&gt;';
              for($k=1;$k&lt;6;$k++){
                  if($rat+0.5&gt;$k)$class="star_".$k."  ratings_stars ratings_vote";
                  else $class="star_".$k." ratings_stars   ratings_blank";
                  echo '&lt;div class="'.$class.'"&gt;&lt;/div&gt;';
                  }
              echo' &lt;div class="total_votes"&gt;&lt;p class="voted"&gt; Rating:     &lt;strong&gt;'.@number_format($rat).'&lt;/strong&gt;/5 ('.$v. '  vote(s) cast) 
          &lt;/div&gt;
      &lt;/div&gt;&lt;/div&gt;';}
   ?&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>