-2

i am sending this to the API and receiving this in return

URL/list?limit=10&page=1

{
    "code": 1,
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 30,
                "first_name": "jack",
                "last_name": null,

            },
            {
                "id": 31,
                "first_name": "Bean",
                "last_name": null,

            },
            {
                "id": 32,
                "first_name": "Stock",
                "last_name": null,

            },
            {
                "id": 33,
                "first_name": "Tangled",
                "last_name": null,


            },
            {
                "id": 34,
                "first_name": "Anna",
                "last_name": null,

            },
            {
                "id": 104,
                "first_name": "Tom",
                "last_name": "M",

            }
        ],
        "from": 1,
        "last_page": 2,
        "last_page": 2,
        "next_page_url": "URL/list?page=2",
        "path": "URL/list",
        "per_page": "10",
        "prev_page_url": "NULL",
        "to": 10,
        "total": 19
    },
    "msg": "Success"
}

now what i want to do is do a simple pagination but i do not know how to go about it using this particular data can some one please help me out what i think should be used is a bit of PHP jquery(AJAX) and html but i can no seem to get it i am very new to this and if some one could help me out it would be great

Please note i have no control over what the JSON Data thus i can not change it

1 Answers1

2

Cannot post as a comment due to low reputation but I do want to say this.

StackOverflow isn't a place where you can just pawn off your dirty work on others here. You have to at least give your best shot and tell us where you're stuck with in order for people to help you.

Here's a few resources on learning Pagination with PHP as well as several other answers on this site that help others with Pagination.

http://www.phpfreaks.com/tutorial/basic-pagination

Simple PHP Pagination script

http://codingcyber.org/simple-pagination-script-php-mysql-5882/

Most of these scripts you find will include MySQL, but for your array you would use array_split() in your case. Unless the data you're providing is also from MySQL then these will work great for you.

Cameron
  • 77
  • 1
  • 9