我创建 php 文件以从数据库中获取所有任务,但是当我在浏览器中输入 url“localhost/evisiting/get_all_task.php”时,它会获取所有任务详细信息,但每行中都有空数据。但是我填充了我的数据库表。请指导我如何从数据库中获取这些值而不是空值..
它是我的 php 文件:
get_all_task.php
<?php
/*
* Following code will list all the tasks
*/
// array for JSON response
$response = array();
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// get all task from my_task table
$result = mysql_query("SELECT *FROM my_task") or die(mysql_error());
// check for empty result
if (mysql_num_rows($result) > 0) {
// looping through all results
// task node
$response["my_task"] = array();
while ($row = mysql_fetch_array($result)) {
// temp user array
$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"];
// push single task into final response array
array_push($response["my_task"], $my_task);
}
// success
$response["success"] = 1;
// 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);
}
?>