I'm having an issue with with a PHP function displaying multiple sums instead of just one when I use array_sum. I'm using phpMyAdmin and the two database tables for this function. These are the tables:
games:

cart:

function total_price() {
$total = 0;
global $con;
$ip = getIP();
$select_price = "select * from cart where ip_add = '$ip'";
$run_price = mysqli_query ($con, $select_price);
while ($g_price = mysqli_fetch_array($run_price)) {
$Cart_Game_ID = $g_price['g_ID'];
$cart_price = "select * from games where Game_ID = '$Cart_Game_ID'";
$run_game_price = mysqli_query($con, $cart_price);
while($pp_price = mysqli_fetch_array($run_game_price)){
$Game_Price = array($pp_price['Game_Price']);
$values = array_sum($Game_Price);
$total += $values;
}
echo "$" . $total;
}
}
Every game in my database costs $20. There are currently 5 games in my database. When I run this function I get $20$40$60$80$100. All i need is the $100. Not the previous 4 sums.
loops, ...