I have a php script that returns me a JSON string of varchar(50) elements. I would like to sum all those numbers together and store them in a variable. Is it possible? Maybe loop trough it...
This is the output of my JSON string:
`12345678910111213141516`
PHP code
<?php
include_once("./conn.php");
if(isset($_POST["toggle_btn"])){
if(!empty($_POST["zone_field"])){
$sql = "SELECT * FROM results";
$res = $conn->query($sql);
if ($res->num_rows > 0) {
while($row = $res->fetch_assoc()) {
echo json_decode($row['waarde']);
}
} else {
echo "No rows have been found";
}
$conn->close();
} else {
echo "Field is empty";
}
} else {
echo 'Did not hit the btn';
}
?>
Thanks a lot