それは私のphp読み取りデータベースファイルです:
<?php
// read_My_Task.php
/*
* Following code will get single task details
* A task_detail is identified by task id (cid)
*/
// array for JSON response
$response = array();
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// check for post data
if (isset($_GET["cid"])) {
$cid = $_GET['cid'];
// get a task from my-task table
$result = mysql_query("SELECT *FROM my_task WHERE cid = $cid");
if (!empty($result)) {
// check for empty result
if (mysql_num_rows($result) > 0) {
$result = mysql_fetch_array($result);
$my_task = array();
$my_task["cid"] = $result["cid"];
$my_task["cus_name"] = $result["cus_name"];
$my_task["contact_number"] = $result["contact_number"];
$my_task["ticket_no"] = $result["ticket_no"];
$my_task["task_detail"] = $result["task_detail"];
// user node
$response["my_task"] = array();
array_push($response["my_task"], $my_task);
// echoing JSON response
echo json_encode($response);
}
else {
// no task found
$response["success"] = 0;
$response["message"] = "No task found";
// echo no users JSON
echo json_encode($response);
}
} else {
// no task found
$response["success"] = 0;
$response["message"] = "No task found";
// echo no users JSON
echo json_encode($response);
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>
データベースには大量のデータがありますが、常に「{"success":0,"message":"Required field(s) is missing"}」という結果が表示されます
MySql データベースに保存されているデータを表示する方法