function getCookHistory($useridParm, $deviceidParm) { // Get list of cooks from database // Check to see if User exists in database $cookhistorysql = "SELECT fldCookID as cookid, fldCookName as cookname, fldCookDate as cookdate, fldCookStartTime as cookstartime, fldCookEndTime as cookendtime FROM tblcooks WHERE fldUserID = ".$useridParm." and fldDeviceID = ".$deviceidParm; // echo $cookhistorysql; $cookhistoryresult = dbQuery($cookhistorysql); $cook_count = dbNumRows($cookhistoryresult); $totalLogFiles = 0; if ($cook_count > 0) { // We have list of cooks $c = 0; while($row = dbFetchAssoc($cookhistoryresult)) { extract($row); $results_json[] = $row; // Format time into AM/PM $results_json[$c]['cookstartime'] = date("g:i a", strtotime($cookstartime)); $results_json[$c]['cookendtime'] = date("g:i a", strtotime($cookendtime)); // Set Cook details $cookfilename = $_GET['userid'].'_'.$_GET['deviceid'].'_'.$cookid.'.txt'; $results_json[$c]['cook_filename'] = $cookfilename; $results_json[$c]['cook_file_exists'] = file_exists('BBQRemoteCooks/BBQ_Graph_'.$cookfilename); if (file_exists('BBQRemoteCooks/BBQ_Graph_'.$cookfilename)) { $totalLogFiles++; } $c++; } //update Total Log files in the user table $updateLogsql = "UPDATE tblusers set fldCookTotalLogFiles = ".$totalLogFiles." WHERE fldUserID = ".$useridParm; // echo $updateLogsql; $updateLogresult = dbQuery($updateLogsql); $json_header = array("status" => "OK", "message" => "Cook History for this user and device", "cook_base_uri" => "http://www.appdesigngeeks.com", "cook_base_dir" => "/appdesign/bbqguru/BBQRemoteCooks/", "cook_count" => $cook_count, "cook_history" => $results_json, "userid" => $_GET['userid'], "deviceid" => $_GET['deviceid']); return json_encode($json_header); } else { $json_header = array("status" => "ERROR", "message" => "No Cooks available for this user/device", "userid" => $_GET['userid'], "deviceid" => $_GET['deviceid']); return json_encode($json_header); } }