So you query the database, set your limit for the number of data entries per page, and proceed to create your pagination. By itself, PHP would require that each link of your pagination reload the page with the query and by doing so, you would query the database again and again, and this obviously impacts the speed of navigation.
A combination of PHP and AJAX, enables you to query the database only once, when the page is loaded. Since AJAX is used to split the query results into multiple pages, there is no need to reload the page as you navigate through the query results.
Although there are a number of different methods of combining PHP and AJAX to achieve pagination, I suggest having a look at one or all of the sources below: