The AVG() function returns the average value of a numeric column.
To understand AVG function, consider an products table, which is having following query
First you can need database connection in php
Code
$sql = "SELECT AVG(price) FROM Products";
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_assoc($result))
{
}