Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用JSON数据在PHP网页上分页_Php_Html_Json - Fatal编程技术网

使用JSON数据在PHP网页上分页

使用JSON数据在PHP网页上分页,php,html,json,Php,Html,Json,我是Php的初学者。我有从REST服务获得的Json数据。我想通过不同的页面将JSON数据分页到表中。我在第一页上检索数据,但剩余的数据并没有显示在该页上,这就是为什么我要在表上显示分页。我访问了那个网站,但我没有完全理解它。下面是我从REST服务获得的json数据 [ { "bookingid": 75, "booking_Id": null, "bookingNumber": "BK201881966", "customerName": "", "cu

我是Php的初学者。我有从REST服务获得的Json数据。我想通过不同的页面将JSON数据分页到表中。我在第一页上检索数据,但剩余的数据并没有显示在该页上,这就是为什么我要在表上显示分页。我访问了那个网站,但我没有完全理解它。下面是我从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,在第2页中,您将偏移设置为5,在第3页中,您将偏移设置为10

为了获得更好的答案,请使用PHP代码编辑您的问题


希望有帮助

欢迎来到StackOverflow。您已经链接到一个工作示例,关于分页,您不了解的是什么?”在第3页中,您将偏移量设置为3“您的意思是10?是的,很抱歉,但您必须友好地进行。