"I can't use a database for this."
AJAX call using JQuery. You'll undoubtedly have the PK id on the page, so simply send that in the call to your PHP page.
Pull the record with the id to ensure it's valid, determine if it's currently flagged as completed or not and return that to the client.
From there, changing the color is easy. $('(insert selector)').css('color','green'); in your success: function(data) { } (one of the $.ajax object parameters). Keep in mind you're returning JSON, so you'll need to parse it. var blah=$.parseJSON(data); for example.
Code
$.ajax example:
//get the pk either using getElementById or $('-')
$.ajax({
datatype: "json",
method: "post", // you'll receive the values you send in the post superglobal
url: "your php page",
data: {
record_id: id //accessed as $_POST['record_id'] with the value of id on receiving page
},
timeout: 15000,
async: false,
success: function(data) {
var blah=$.parseJSON(data);
if ( blah['completed'] ) {
//We completed within php page
$('selector').css('color','green');
} else {
$('selector').css('color','red');
}
}
});
return values from the php page to the client using print json_encode($value);
As for writing it to a CSV, that's fairly straight forward. Create a buffer string with your headers separated by commas. Write it to the file. Rewrite buffer with your values in a loop, write to file every iteration.
This post was edited by Blizane on Dec 2 2016 10:50am