Implementation of Ajax without refreshing paging instance code and ajax paging instance code
Today we are going to use ajax to make a page:
Implement Ajax paging:
If possible, add the query conditions.
- Find a table for paging
- Pagination does not use the page class
- Page does not need to be refreshed
- Load data using Ajax
<! Doctype html>
Above is the page: test. php
<? Phpinclude ("DBDA. class. php "); $ db = new DBDA (); // pass the two values of the previous page to $ page = $ _ POST [" page "]; // $ key = $ _ POST ["key"] on the current page; // condition, keyword $ num = 20; // defines the number of data entries on a page, $ tiaoshu = ($ page-1) * $ num; // how many records are skipped by $ tiaoshu ($ page-1) * $ num now $ num is 20 // write $ SQL statement $ SQL = "select * from chinastates where areaname like '% {$ key} % 'limit {$ tiaoshu }, {$ num} "; // query like '% {$ tiaojian} %' based on the keyword '. Echo $ db-> JSONQuery ($ SQL );
The above is the processing page: chuli. php:
<?phpinclude("DBDA.class.php");$db = new DBDA();$key = $_POST["key"];$num = 20;$sql = "select count(*) from chinastates where areaname like '%{$key}%'";$zts = $db->StrQuery($sql);echo ceil($zts/$num);
The above is a paging page: fenye. php
The following figure shows the display effect:
As you click the next page, five pages are displayed, and two pages are displayed on both the left and right sides of the current page. You can adjust the number of information displayed on each page.
Enter keywords in the text box above to display relevant information. This is the page we use ajax to do.
The above is the Ajax Implementation of the example code for refreshing pagination. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!