Make Pagination using Ajax with Jquery, PHP and MySQL

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends in this video we are going to learn how to create simple pagination by using Ajax which query PHP in my SQL without refreshing page in the web application pagination is a very important part where huge numbers of records are listed from the database in that case Ajax query pagination is a preferable way because it will help to improve the speed of data load of your website this video tutorial will show how can you implement the Ajax pagination and PHP using jQuery and MySQL I have developed the simple and powerful script to create pagination with jQuery AJAX PHP and MySQL this is my database with name testing in this database I have one table student with three column like student ed student name and student phone I have already inserted sixteen data into this table now I want to show this data on web page with simple Ajax pagination by using PHP I will display the student data from the MySQL database with the pagination links through this pagination links you can get the database records except the displayed records jQuery and Ajax will help to get the records from the database depending on pagination links without reloading the page this is my index dot PHP web page on which I will display student data and Ajax pagination on this page I have used JavaScript libraries query for calling Ajax function on this page first I have write one division tag with attribute like it is equal to pagination data between this tag I will display student data with pagination which data get from one pagination dot PHP page by calling Ajax function first I have moved to write some query code to call pagination dot PHP page by using query with Ajax for this first I have make unfunctional Oh data with one parameter page in this function I have will write Ajax function code for this I have write Ajax function with first parameter like URL set to pagination dot PHP peer URL is a string containing the URL to which the request is sent it will send request to this pagination dot PHP page second I have write method with post method here method is the HTTP method to use for the request here I have used post method third is data here we can set which data you want to sent to server and it will be converted into a query string here I want to send page data to the server which get from load a to function parameter like page and last is the success callback function this is a function to be called if the request succeeds here if the data get from pagination dot PHP page then this function will be called an all data which it will get from pagination dot PHP page will store into this function date the parameter from pagination dot PHP page we can get the student table data with pagination link and this store into this data parameter now I want to display data between this division tag with it like pagination data so for this I have write dollar with selector like pagination data dot HTML method with data this way we can display whichever student data with pagination link into this division tag within pagination data now I have moved to write PHP code into pagination dot PHP in this page will fetch student data from table and display into table format and also make pagination linked also first I have made database connection for database connection first I have defined one variable connect is equal to miss lis connection function with parameter host is equal to locale lost username is equal to root password is equal to blank and database name is equal to testing database first and pagination how many records should be display on per page for this I have defined one variable record per page is equal to five that means I want to display only five records on single page and other records will display on next page now I have defined one new variable page is equal to blank in this variable I will store current page number and it will be anything like 1 2 3 etc after this I have write one more variable with name like output is equal to blank in this variable I will store data get of student which we have get from table in HTML format and in this I will also store pagination link also and this data will display callback to index dot PHP page bar Ajax after this I want to check and URL there is page variable is present or not for this I have write of statement with condition in condition I have used sip function with parameter dollar post page data than page variable is equal to dollar post page data this page variable will be get form Ajax function which have called from index dot PHP page but suppose if there is no page value get from Ajax called Dan page variable value will be equal to 1 now friends I have defined one new variable start from is equal to page variable minus 1 into record per page variable which I have defined above it will be used and to select query and in that select query it will define from which number to start selecting of data from table after this I want to make select SQL query for fetching data from table student for this I have defined one new variable query is equal to select start from table student order by student in descending order limit dollars start from variable comma dollar record per page variable now I have want to execute this query and store records in one variable for this I have defined one variable result is equal to miss click query function with two parameter first is database connection string is equal to connect and SQL query is equal to query this way we can execute select query and results through and to resolve variable before fetch all data first I have defined table with two columns name and phone for this I have write output variable is equal to table with one row and two table column name like name and phone now friends I have use while loop for fetching all data from database in while loop I have right dollar row variable is equal to miss Li fetcher a function with parameter MySQL query result which I have store into resolved variable this function will convert my SQL query result into associative array and store into row variable now I simply print data like student name and student phone onto table for this first I have write output variable with string concatenation operator equal to and I have write open and close table row and between this I have write to open and close table data for student name I have write dollar row a table column name like student name and for student phone I have write dollar row a table column name like student phone after this I want to clothes the table tag for this I have write output variable is equal to close table tag and after this I have write HTML break tag and then after I have write division tag with a line is equal to Center this we can fetch data from student table and store into this output variable in HTML form now I have moved to write PHP code for pagination link for this first I have defined one variable page query is equal to select start from table student order by student in descending order after this I want to execute this query and store a result for this I have defined one new variable page result is equal to miss click query function with two parameter one is database connection string and second is a skew l query after this I want to get total number of records in table for this I have defined one variable total records is equal to miss clean am rows function with parameter like my SQL query result which I have stored into page result result variable friends after getting total number of records now I want to get total number of pages for this I have defined one variable total pages is equal to seal function this function will rounds a number up to the nearest integer in this function I have write total records variable divided by record per page variable with the help of this code we can get total pages now friends I want to display all pages with its respective link to particular page for this I have use for loop so I have write 4 with open and closed bracket and between bracket I have write dollar I is equal to one dollar I less than equal to total pages and dollar I plus plus between for-loop I want to print pages number for this I have again write out what variable is equal to open span tag with class name is equal to pagination link I will use this class name as a selector inch query code I want to format this tag so for this I have write style attribute is equal to cursor property set the pointer padding style property set to six pixel and set border with border with one pixel with border-style:solid and set border color to blank after this I have right attributed is equal to dollar I and in spandex I have also write this dollar I which is dynamic fell you get from for loop and close span tag this way we can create pagination page link and store into this output variable now I have rights simple echo statement and write output variable in which I have store all student data into HTML form and this will display at the index dot PHP page on this index dot PHP page first I want to call this load data function so for this I have write load data function by writing this function whenever page below this function will called and it will fetch data from student table by using Ajax and it will display on this page now I have saved this code I'm check output in browser you friends when you have click on page number table date and not change for change data we have to write each query code on when user click on page number than at that time table data should be changed according to page number on which he clicked so for this I have wrote dollar with selector like document with on method and in this method I have right click event selector pagination link which is class name of span tag and one function here I have used on method this is because with help of this method we can work with more than one event you in this function I have write one page variable is equal to dollar this selector with attribute method and in this I have write to attribute in this code when used click on this whichever page number we can get the aid of that span tag by using this selector and store into this page variable now I have simply called load data function and in parameter of this function I have passed this page variable value suppose page variable value is equal to 3 then this 3 value will be passed into this load data function and by this function we can pass this value to pagination dot PHP page var ajak sent from pagination dot PHP page will return back data regarding the page 3 value and it will display on web page without page refresh you so friends this is my simple video tutorial on how to create simple pagination from data without refreshing of page by using Ajax which query PHP in my SQL if you have any question regarding this video tutorial you can comment on this video under comment box we will definitely answer your query if you liked this video please share this video with your friends or even you can share on social media also friends you want to get more update of my video so friends you can subscribe my youtube channel friends you can also like my Facebook page also or you can also follow webs listen on Twitter
Info
Channel: Webslesson
Views: 58,406
Rating: undefined out of 5
Keywords: ajax pagination, pagination with jquery ajax and php, pagination in php using ajax, simple pagination with Ajax in php, pagination in php using jquery, pagination in php using ajax and jquery, pagination with jquery php ajax and mysql, ajax pagination in php, pagination without page refresh, php pagination using ajax, simple ajax pagination, simple pagination in php using jquery, pagination with jquery, create ajax pagination
Id: 6Ou-FCoW--Q
Channel Id: undefined
Length: 16min 1sec (961 seconds)
Published: Thu Aug 18 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.