i have a little bit problem with my following code. I am trying to make a star raiting system and following code is showing raiting details. But i am getting
undefined variable rate_db notice
from if(count($rate_db)) What i missing here anyone can tell me please ?
full code is here:
    <?php
      $query = mysqli_query($db,"SELECT ryid,r_type FROM profileRaiting WHERE rp_uid='$profile_uid'"); 
        while($data = mysqli_fetch_assoc($query)){
           $rate_db[] = $data;
           $sum_rates[] = $data['r_type'];
        }
        if(count($rate_db)){
          $rate_times = count($rate_db);
          $sum_rates = array_sum($sum_rates);
          $rate_value = $sum_rates/$rate_times;
          $rate_bg = (($rate_value)/5)*100;
        } else {
           $rate_times = 0;
           $rate_value = 0;
           $rate_bg = 0;
        }
 ?>
 
     
     
     
     
     
    