js简单输出数据到前端页面

前端html:test.html




    
    
    
    
    
    Document
    


ID 设备 手机电话 项目标题 用户姓名 一级分类 二级分类 留言 日期

接口数据:

 connect_errno){
    die('连接错误' . $mySQLi -> connect_error);
}
$mySQLi -> set_charset('utf8');
$sql = "select * from wp_user_info order by post_date desc";
$res = $mySQLi -> query($sql);

$resp = [
    'code' => -1
];
if(empty($res)){
    $mySQLi -> close();
    echo json_encode($resp);
    exit;
}
$dataArr = [];
while($row = $res -> fetch_object()){
    $dataArr[] = [
        'ID'    => $row->post_id,
        'title' => $row->title,
        'name'  => $row->name,
        'cate'  => $row->cate,
        'zcate'  => $row->zcate,
        'message'  => $row->message,
        'phone'  => $row->phone,
        'post_date'  => $row->post_date,
        'device' => $row->device
    ];

}
$mySQLi -> close();
$resp['code'] = 200;
$resp['data'] = $dataArr;
echo json_encode($resp);
exit;

 

 

 

 

 

 

 

你可能感兴趣的:(php)