PHP query page implementation code, PHP page implementation code

Source: Internet
Author: User

PHP query page implementation code, PHP page implementation code

The examples in this article share the code for querying pages in PHP. the backend is based on the thinkphp framework for your reference. The specific content is as follows:

The front-end requires the dataTables plug-in: Portal

HTML code

Step 1 introduce the plug-in

<!-- DataTables CSS --><link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.15/css/jquery.dataTables.css" rel="external nofollow" ><!-- jQuery --><script type="text/javascript" charset="utf8" src="http://code.jquery.com/jquery-1.10.2.min.js"></script><!-- DataTables --><script type="text/javascript" charset="utf8" src="http://cdn.datatables.net/1.10.15/js/jquery.dataTables.js"></script>

Step 2 add

<Table id = "table_id_example" class = "display"> <thead> <tr> <th> ID </th> <th> release date </th> <th> IP </th> <th> announcement content </th> </tr> </thead> <tbody> <volist name = "notice" id = "vo"> <tr> <td> {$ vo. id} </td> <td >{$ vo. create_time} </td> <td> {$ vo. create_ip} </td> <td> {$ vo. notice_content }</td> </tr> </volist> </tbody> </table>

Step 3. JS

 <script> $(document).ready( function () {  $('#table_id_example').DataTable(); } ); </script>

PHP code

Public function gonggaochakan () {/* view announcement */$ dbNotice = M ('notice '); // instantiate the dbNotice object $ count = $ dbNotice-> count (); // query the total number of records meeting the requirements $ Page = new \ Think \ Page ($ count, $ count ); // instantiate the total number of incoming records and the number of records displayed on each page (all records) $ data = $ dbNotice-> order ('create _ Time ') -> limit ($ Page-> firstRow. ','. $ Page-> listRows)-> select (); // obtain all records $ this-> assign ('notice ', $ data ); // send the template $ this-> show ();}

Effect

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.