<?php
require 'config.php';


$sql="SELECT * FROM reviews WHERE  provider_id = '$provider_id'";
$result=$con->query($sql) or die ("error: Server error ".mysqli_error($con));
$count=mysqli_num_rows($result);


$resultx = mysqli_query($con, "SELECT SUM(rating) AS value_sum FROM reviews WHERE  provider_id = '$provider_id'"); 
$row = mysqli_fetch_assoc($resultx); 
$sum = $row['value_sum'];

$rating = $sum/$count;



$sqlz="UPDATE users set rating = '$rating'  WHERE user_id = '$provider_id'";
$resultz=$con->query($sqlz) or die ("error2: Server error ".mysqli_error($con));

     

?>
