To change a webpage or html background based on what a PHP variable is, follow this guide:
For practical purposes if a profile is online the PHP variable = 1 making the background green otherwise make it red for 0.
functions.php
function is_online($id){ $data = json_decode(file_get_contents("https://someurl/profile?userid=" . $id . "")); $status = $data->response->status; if($status == 1){$color = 'green';}else{$color = 'red';} return $color; }
<?php include('functions.php');?> <html> <head></head> <body style='background-color : <?php echo is_online(5681);?>' <h1>More html here</h1> </body> </html>
If profile 5681 is online as per the mock API call in functions.php then the background will be green otherwise the background will be red.