query('SELECT animalID FROM animals where qr= "'.$qr .'" AND eventID = "'.$eventID.'"'); $statement->setFetchMode(PDO::FETCH_ASSOC); $results = $statement->fetchAll(); $statement2 = $db->query('SELECT stagingID, stagingName FROM staging where eventID = "'.$eventID.'"'); $statement2->setFetchMode(PDO::FETCH_ASSOC); $results2 = $statement2->fetchAll(); //$array1 = array("color" => "red", 2, 4); //$array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4); $arrayResult = array_merge($results, $results2); if ($arrayResult){ echo json_encode($arrayResult); }else{ $success['ok']= false; echo json_encode($success); } //echo json_encode($statement->fetchAll()); } if ($_SERVER['REQUEST_METHOD'] == "POST"){ $sql = "INSERT INTO locations (animalID, lat, lon, address, created_by, pic, comments, stagingID) values (:animalID, :lat, :lon, :address, :created_by, :pic, :comments, :stagingID)"; $query = $db->prepare($sql); if($query->execute(array( ":animalID"=>$data->animalID, ":lat"=>$data->lat, ":lon"=>$data->lon, ":address"=>$data->address, ":created_by"=>$data->created_by, ":pic"=>$data->pic, ":comments"=>$data->comments, ":stagingID"=>$data->stagingID ))){ $success['ok'] = true; echo json_encode($success['ok']); }else{ $success['ok'] = $db->errorInfo(); echo json_encode($success['ok']); } } if ($_SERVER['REQUEST_METHOD'] == "PUT"){ $sql = "UPDATE users SET combo = :password WHERE userID = :userID"; $query = $db->prepare($sql); if($query->execute(array(":password"=>$data->password, ":userID"=>$data->userID))){ $result['id'] = $db->lastInsertId(); echo json_encode($result); }else{ $error['error'] = 'error'; echo json_encode($error); } } ?>