I'm trying to add all the values from the \[code\]grade_points\[/code\] field for example \[code\]10, 12.5, 2.1\[/code\] and then divide it by how many times grade points where entered into the database for example \[code\]24.6 / 3\[/code\].I know that \[code\]$total_rating_points\[/code\] is an array but I don't really know how to convert the array so I can add the total grade points and then divide it by how many times points where entered. I was hoping if someone can help me out with this problem? That I have been working on forever.Here is the code I'm having trouble on.\[code\]$sql2 = "SELECT grade_points FROM grades JOIN articles_grades ON grades.id = articles_grades.grade_id WHERE articles_grades.users_articles_id = '$page'";$result = mysqli_query($dbc,$sql2);if (!mysqli_query($dbc, $sql2)) { print mysqli_error($dbc); return;}$total_rating_points = mysqli_fetch_array($result);if (!empty($total_rating_points) && !empty($total_ratings)){ $avg = (round($total_rating_points / $total_ratings,1)); $votes = $total_ratings; echo $avg . "/10 (" . $votes . " votes cast)";} else { echo '(no votes cast)';}\[/code\]Here is the full code I'm working on.\[code\]function getRatingText(){ $dbc = mysqli_connect ("localhost", "root", "", "sitename"); $page = '3'; $sql1 = "SELECT COUNT(users_articles_id) FROM articles_grades WHERE users_articles_id = '$page'"; $result = mysqli_query($dbc,$sql1); if (!mysqli_query($dbc, $sql1)) { print mysqli_error($dbc); return; } $total_ratings = mysqli_fetch_array($result); $sql2 = "SELECT grade_points FROM grades JOIN articles_grades ON grades.id = articles_grades.grade_id WHERE articles_grades.users_articles_id = '$page'"; $result = mysqli_query($dbc,$sql2); if (!mysqli_query($dbc, $sql2)) { print mysqli_error($dbc); return; } $total_rating_points = mysqli_fetch_array($result); if (!empty($total_rating_points) && !empty($total_ratings)){ $avg = (round($total_rating_points / $total_ratings,1)); $votes = $total_ratings; echo $avg . "/10 (" . $votes . " votes cast)"; } else { echo '(no votes cast)'; }}\[/code\]