我必须将我的应用中的日期时间值发送到托管服务器上的API,然后将所有日期值以后的日期时间(从应用程序发送)从我的主机上的数据库表格中获取并显示在日期中日志。
DB_Functions.php
/**
* Get dates from database
*/
public function getDate_of_upload_file($date_of_upload_file) {
$result = mysql_query("SELECT * FROM docs WHERE created_at = '$date_of_upload_file_phone'") or die(mysql_error());
// check for result
$no_of_rows = mysql_num_rows($result);
if ($no_of_rows > 0) {
$result = mysql_fetch_array($result);
}
return $result;
}
的index.php
// Checking dates of documents
if ($tag == 'date_of_documents') {
$date_of_upload_file = $_POST['date_of_upload_file'];
// check for documents
$date_of_upload_file = $db->getDate_of_upload_file($date_of_upload_file);
if ($date_of_upload_file != false) {
// documents found
// echo json with success = 1
$response["success"] = 1;
$response["user"]["date_of_upload_file"] = $user["date_of_upload_file"];
echo json_encode($response);
} else {
// documents not found
// echo json with error = 1
$response["error"] = 1;
$response["error_msg"] = "Incorrect date_of_upload_file!";
echo json_encode($response);
}
}
UserFunctions.java
/**
* Function to Get Date of Document
**/
public JSONObject get_data_of_upload_file(){
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("tag", documents_tag));
params.add(new BasicNameValuePair("date_of_upload", date_of_upload));
JSONObject json = jsonParser.getJSONFromUrl(loginURL, params);
return json;
}
Main.java
@Override
protected JSONObject doInBackground(String... args) {
UserFunctions userFunction = new UserFunctions();
JSONObject json = userFunction.get_data_of_upload_file();
return json;
}