php json 查看返回值,js用json调用php并显示返回值

图片1是一个接送记录,图片2是这个记录的一个接口,怎么用js调用这个php然后在网页上显示那些返回值,怎么弄的,php中的代码也附上了

28ff1a54ff58a55b3dbe086fa8a16d53.png

3a39dbfefe28969462aea5c430a2fa73.png

require('../../../incode/user_fns.php');

function __autoload($class_name) {

require_once '../../../incode/'.$class_name.'.php';

}

if (isset($_COOKIE['userid'])) {

$userid = intval(trim($_COOKIE['userid']));

} else {

error_exit(ENOPOST);

}

if (isset($_COOKIE['token'])) {

$usertoken = trim($_COOKIE['token']);

} else {

error_exit(ENOPOST);

}

if (!$usertoken || !$userid) {

error_exit(ENOPOST);

}

if (isset($_POST['year'])) {

$year = intval(trim($_POST['year']));

} else {

error_exit(ENOPOST);

}

if (isset($_POST['month'])) {

$month = intval(trim($_POST['month']));

} else {

error_exit(ENOPOST);

}

if (!$year || !$month) {

error_exit(ENOPOST);

}

$page = 0;

if (isset($_POST['page'])) {

$page = intval(trim($_POST['page']));

}

$count = 10;

if (isset($_POST['pcount'])) {

$count = intval(trim($_POST['pcount']));

}

try{

db_connect();

$registry =& Registry::getInstance();

$conn =& $registry->get('dbconn');

if (!check_accesstoken($userid, $usertoken)) {

error_exit(EUSERTOKEN);

}

$result = $conn->query("select bbid from user where userid=$userid");

if (!$result) {

error_exit(EDBSELECT);

}

$row = $result->fetch_row();

if (!$row) {

error_exit(EBABYNOTEXIST);

}

$bbid = $row[0];

$result = $conn->query("select cardid from accesscard where bbid=$bbid");

if (!$result) {

error_exit(EDBSELECT);

}

$resultarray = array();

$starttime = strtotime("$year-$month-1");

$month++;

$endtime = strtotime("$year-$month-1");

$pagestart = $page*$count;

$result = $conn->query("select checkid,parent,time,status from checkin where bbid=$bbid and time>$starttime and time

if (!$result) {

error_exit(EDBSELECT);

}

while ($row = $result->fetch_row())

{

if (connection_aborted() || connection_status()!=CONNECTION_NORMAL) {

exit;

}

$lasttime = $row[2];

$checkin['checkid'] = $row[0];

$checkin['parent'] = $row[1];

if (!$row[1]) {

$result1 = $conn->query("select name from user a,checkin b where b.checkid='".$row[0]."' and a.userid=b.cardid");

if (!$result1) {

error_exit(EDBSELECT);

}

$row1 = $result1->fetch_row();

if (!$row1) {

continue;

}

$checkin['teacher'] = $row1[0];

}

$checkin['time'] = $lasttime;

$checkin['status'] = $row[3];

$resultarray[] = $checkin;

}

echo json_encode($resultarray);

}catch (Exception $e) {

error_exit($e->getCode());

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值