I'm a newbie, so be kind :)
What is the simplest solution for checking for, retrieving and using newly received data from a mysql database?
The database is being updated from an external api. Ideally I would get it as it arrives but using intervals could work too. On the first iteration and then once every 5 minutes if there is no new data meanwhile - do an action with the next entry of the array which might cause data to be updated within the next 5 min. But I want to make sure to stop everything if the new data has been received, and just perform some stuff in php.
what's the most simple solution? php vs jquery/ajax?
my proposed solution is in jquery:
<script>
var newdata = false;
if(newdata === false){
setTimeout (function(){
$.each(array, function(){
$.post('checkdb.php',data,function(resp){
if(resp){
newdata=resp;
return newdata;
}
else{
$.post('doaction.php',data);
// cause a potential update within the next 5 min
}
});
});
}, 300000);
}
else{
// move newdata back to php and (then) do something with response
}
</script>
Thanks! :)