How does jquery-php operate array paging?

Source: Internet
Author: User
New guy .. The company has a php trainer project. Now there is a problem: the company uses QeePHP relatively old, and then the company's Projects basically use the database query framework, then, you can use the SQL limit to limit the paging filtering of data. Because the data I want needs to be merged and arranged... newcomers .. The company has a php trainer project. Now there is a problem: the company uses QeePHP relatively old, and then the company's Projects basically use the database query framework, then, you can use the SQL limit to limit the paging filtering of data.
Because the data I want needs to be merged and sorted .. All the read data is saved in a large array. Now there is no problem with the data display and the search function is complete. All data can be displayed on the webpage. However, the paging function is not implemented. Hope you can provide some ideas .. The company's colleagues used the jQuery method and the array_slice method seem to be able to basically complete paging .. But it is not particularly understandable .. I wonder if there is any better method ..
Thank you ~

Reply content:

New guy .. The company has a php trainer project. Now there is a problem: the company uses QeePHP relatively old, and then the company's Projects basically use the database query framework, then, you can use the SQL limit to limit the paging filtering of data.
Because the data I want needs to be merged and sorted .. All the read data is saved in a large array. Now there is no problem with the data display and the search function is complete. All data can be displayed on the webpage. However, the paging function is not implemented. Hope you can provide some ideas .. The company's colleagues used the jQuery method and the array_slice method seem to be able to basically complete paging .. But it is not particularly understandable .. I wonder if there is any better method ..
Thank you ~

Paging has several elements
Define ('page _ length', 15); // number of entries per PAGE
$ Total_count = count ($ data_array); // number of data entries
$ Total_pages = ceil ($ total_count/PAGE_LENGTH); // total number of pages
$ Current_page = $ _ GET ['page']; // the current page number.
$ Page_list = range (1, $ total_pages); // page list. Of course, if there is only one page or no data, you need to judge it.

Also, when the page data
$ Data = array_slice ($ data_array, ($ current_page-1) * PAGE_LENGTH, PAGE_LENGTH); // retrieve data from either a big data or a database.

Personal experience, paging is generally for two points. 1. UI display optimization 2. Loading Speed Optimization
If it is a simple interface display optimization, this is very simple. We recommend that you use open-source jquery plug-ins, such as datatable, to display your data and use ajax to pass values;
If the second type is used, it generally corresponds to a large amount of data, such as an enterprise report. It is best not to extract all the data and perform merge and rank operations, which leads to high memory overhead and poor user experience. The correct method should be to load a small amount of page_size data from the database according to the order by sorting field, and then complete the data.

The framework is still native.
Your question is, how do I paging the page? The mobile phone cannot call the code, but you can search for a demo on Baidu. It's very easy, don't be afraid.

After learning php many years ago, I had forgotten it.

You can download the thinkphp source code, which contains a data paging class. Refer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.