我是Php的初学者。我有从REST服务获得的Json数据。我想通过各种页面将JSON数据分页到表中。我在第一页上检索数据,但其余数据未在该页上显示,这就是为什么我要在表上显示分页。我访问了How to do Pagination for JSON data in PHP?网站,但我对此并不完全了解。以下是我从REST服务获取的json数据。
[
{
"bookingid": 75,
"booking_Id": null,
"bookingNumber": "BK201881966",
"customerName": "",
"customerMobileNumber": "9850944481",
"customerId": null,
"bookingDate": "8/19/2018 12:00:00 AM",
"collection_time": "12:12 AM",
},
{
"bookingid": 76,
"booking_Id": null,
"bookingNumber": "BK201881976",
"customerName": "",
"customerMobileNumber": "9850944481",
"customerId": null,
"bookingDate": "8/19/2018 12:00:00 AM",
"collection_time": "07:05 PM",
},
{
"bookingid": 77,
"booking_Id": null,
"bookingNumber": "BK201882077",
"customerName": "",
"customerMobileNumber": "",
"customerId": null,
"bookingDate": "8/20/2018 12:00:00 AM",
"collection_time": "04:06 PM",
},
{
"bookingid": 79,
"booking_Id": null,
"bookingNumber": "BK201882079",
"customerName": "",
"customerMobileNumber": "",
"customerId": null,
"bookingDate": "8/20/2018 12:00:00 AM",
"collection_time": "07:10 PM",
},
{
"bookingid": 104,
"booking_Id": null,
"bookingNumber": "BK2018820104",
"customerName": "Rakesh Deshmukh",
"customerMobileNumber": "8745938475",
"customerId": null,
"bookingDate": "8/20/2018 12:00:00 AM",
"collection_time": "04:07 PM",
}
{
"bookingid": 82,
"booking_Id": null,
"bookingNumber": "BK201882082",
"customerName": "Muzzameel Sayyad",
"customerMobileNumber": "",
"customerId": null,
"bookingDate": "8/20/2018 12:00:00 AM",
"collection_time": "11:13 PM",
},
{
"bookingid": 83,
"booking_Id": null,
"bookingNumber": "BK201882083",
"customerName": "Muzzameel Sayyad",
"customerMobileNumber": "",
"customerId": null,
"bookingDate": "8/20/2018 12:00:00 AM",
"collection_time": "11:29 PM",
},
{
"bookingid": 99,
"booking_Id": null,
"bookingNumber": "BK201882085",
"customerName": "Customer One",
"customerMobileNumber": "8347829296",
"customerId": null,
"bookingDate": "8/20/2018 12:00:00 AM",
"collection_time": "12:34 PM",
},
{
"bookingid": 103,
"booking_Id": null,
"bookingNumber": "BK2018820100",
"customerName": "Customer One",
"customerMobileNumber": "8347829296",
"customerId": null,
"bookingDate": "8/20/2018 12:00:00 AM",
"collection_time": "11:10 AM",
},
{
"bookingid": 111,
"booking_Id": null,
"bookingNumber": "BK2018821106",
"customerName": "Customer One",
"customerMobileNumber": "8347829296",
"customerId": null,
"bookingDate": "9/6/2018 12:00:00 AM",
"collection_time": "09:10 PM",
}....]
我正在使用count json计数数据
$total_records = count(jsonData); // I got 165 from json
$no_of_records_per_page = 5; // I get 5 records per page
$total_pages = ceil($total_records / $no_of_records_per_page); // I got 33 from that formula
接下来我不会怎么做。帮我完成我的代码。 提前谢谢。
答案 0 :(得分:-1)
您需要一个偏移量来设置要显示帖子的编号。 在第一次加载中,将偏移量设置为0,在第2页中将偏移量设置为5,在第3页中,将偏移量设置为10 ...
要获得更好的答案,请使用您的PHP代码编辑您的问题。
希望有帮助!