Vous pouvez le gérer complètement dans la requête MySQL :
SELECT SUM(column_name) FROM table_name;
Utilisation de PDO (mysql_query
est obsolète)
$stmt = $handler->prepare('SELECT SUM(value) AS value_sum FROM codes');
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$sum = $row['value_sum'];
Ou en utilisant mysqli :
$result = mysqli_query($conn, 'SELECT SUM(value) AS value_sum FROM codes');
$row = mysqli_fetch_assoc($result);
$sum = $row['value_sum'];