I have a simple mysql table with 'ratee' being the user and rating being the rating given to that user. I want to display how many times that user has been rated and what the average of those ratings are. The former works as shown in the code below but the latter does not. Where am i going wrong please? I am using PHP.
//working
$sql = "SELECT * FROM ratings WHERE ratee='" . $user1 . "'";
$result = mysqli_query($conn, $sql);
$ratingsqty = mysqli_num_rows($result);
echo $ratingsqty;
//not working 1
$sql = "SELECT * FROM ratings WHERE ratee='" . $user1 . "'";
$result = mysqli_query($conn, $sql);
$rating = mysqli_avg($result);
echo $rating;
//not working 2
$sql = "SELECT avg(rating) FROM ratings WHERE ratee='" . $user1 . "'";
$rating = mysqli_query($conn, $sql);
echo $rating;