0) ? true : false; } $_sql = "SELECT * FROM `[TableName]` WHERE ..."; // As columns in the table, I created followers, screen_name, and status. // Do not forget to save a screen name to the database before executing the code to avoid any possible error. if(checkDatabase($_sql)){ if($result = mysqli_fetch_assoc(mysqli_query($conn, $_sql))){ $url = "https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names=".$result['screen_name']; $data = json_decode(file_get_contents($url), true); $followers = (int)$data[0]['followers_count']; if((int)$result['followers'] == $followers){ $output = array( "followers" => $result['followers'], "screen_name" => $result['screen_name'], "last_status" => $result['status'], "status" => "STABLE" ); }else if((int)$result['followers'] > $followers){ $__sql = "UPDATE `[TableName]` SET `followers`='$followers', `status`='DEC' WHERE ..."; mysqli_query($conn, $__sql); $output = array( "followers" => $followers, "screen_name" => $result['screen_name'], "last_status" => $result['status'], "status" => "DEC" ); }else if((int)$result['followers'] < $followers){ $__sql = "UPDATE `[TableName]` SET `followers`='$followers', `status`='INC' WHERE ..."; mysqli_query($conn, $__sql); $output = array( "followers" => $followers, "screen_name" => $result['screen_name'], "last_status" => $result['status'], "status" => 'INC' ); } echo "%".$output['followers']."%".$output['screen_name']."%".$output['last_status']."%".$output['status']."%"; } } exit(); ?>