Get the App
SLTechnology News&Howtos  ›  Database  › 

How to use PHP+Ajax to load more list data by clicking

Shulou Source: shulou.com Published: 2022-05-31 18:31:04 10月26日 Update

This article mainly introduces "how to use PHP+Ajax to load more list data". In daily operation, I believe many people have doubts about how to click and load more list data with PHP+Ajax. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "how to use PHP+Ajax to load more list data". Next, please follow the editor to study!

A simple and practical PHP+Ajax click to load more list data instances, the implementation principle: through the "more" button to send Ajax requests to the server, PHP paging parameter query will be the latest several records, data returned in the form of JSON, the foreground Query parses JSON data, and appends the data to the list page. In fact, it is also Ajax paging effect.

Html Code:

:: click to load more:

Introduce the jQuery plug-in and jquery.more.js to load more plug-ins:

$(function () {$('# more') .more ({'address':' data.php'})})

Data.php receives the two parameters submitted by the foreground page, $_ POST ['last'] starts the number of records, and $_ POST [' amount'] displays the number of records at a time. You can see the SQL statement, which is actually the statement used in paging.

Require_once ('connect.php'); $last = $_ POST [' last']; $amount = $_ POST ['amount']; $query = mysql_query ("select * from article order by id desc limit $last,$amount") While ($row = mysql_fetch_array ($query)) {$sayList [] = array ('title' = > ". $row [' title'].", 'author' = > $row [' id'], 'date' = > date (' row ['addtime']));} echo json_encode ($sayList) At this point, the study on "how to click and load more list data with PHP+Ajax" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: More data learning utility foreground parameters plug-ins statements help next two in use code content principles examples that is form buttons effects Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Redmi MariaDB Shulou Technology Linux