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.