I want to add the existing value with the new value when the webpage refresh. I have two files which are the html and php file. The php file will show a random number between 10 and 100. while the html file perform a get jquery to get the data from the php script. Then after webpage refresh, the existing values must be incremented by the new value. For example,
the first value on the webpage is 24.
after refreshing the page, the new value is 89 from the php script
the value on the webpage must be 113 (24+89).
I am going to show you the code below.
showtotal.php
<?php
$random = rand(10,100);
echo $random;
?>
showtotal.html
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
updateFromServer();
var intervalID = window.setInterval(updateFromServer, 500);
function updateFromServer() {
$.get({
url: 'showtotal.php',
dataType: 'text',
success: totalAttacks
});
}
function totalAttacks(val) {
$('#result').html('Events Today' + val);
}
</script>
<h1 id="result"></h1>
</body>
</html>
what my code is show different values in every refresh. How to increment the existing values by the new values? Please help me . thank you