title
PHP Pagination Tutorial MySQLi Google Style Paged Results Programming
description
Code: https://www.adamkhoury.com/PHP/video/Pagination-MySQLi-Google-Style-Paged-Results-Tutorial
Learn to script pagination for PHP and MySQLi based web applications. Use pagination programming when your database table has a lot of rows and you do not want all results to render on a single page.
detail
{'title': 'PHP Pagination Tutorial MySQLi Google Style Paged Results Programming', 'heatmap': [{'end': 603.879, 'start': 559.055, 'weight': 0.751}, {'end': 921.702, 'start': 841.465, 'weight': 0.989}, {'end': 1352.43, 'start': 1311.277, 'weight': 0.864}], 'summary': 'Tutorial series covers setting up php pagination for mysql database, including establishing connections, handling url variables, creating pagination controls, and rendering testimonials, with emphasis on specific php functions and sql query limit syntax.', 'chapters': [{'end': 155.736, 'segs': [{'end': 49.632, 'src': 'embed', 'start': 23.313, 'weight': 1, 'content': [{'end': 28.677, 'text': "Now, since we're going to be querying a MySQL database for all of our data that's going to be paginated,", 'start': 23.313, 'duration': 5.364}, {'end': 32.179, 'text': "we're going to need a MySQL-I based connection to the database.", 'start': 28.677, 'duration': 3.502}, {'end': 35.582, 'text': 'So you have to establish a MySQL-I connection.', 'start': 32.36, 'duration': 3.222}, {'end': 39.164, 'text': 'And you do that right here at the top of your script or somewhere near the top.', 'start': 35.942, 'duration': 3.222}, {'end': 44.268, 'text': 'You just have to make sure that that is in place before you try to query anything from the database.', 'start': 39.485, 'duration': 4.783}, {'end': 49.632, 'text': 'And if you need to see what this MySQLIConnection.php file looks like,', 'start': 44.608, 'duration': 5.024}], 'summary': 'Query mysql database with paginated data, establish mysql-i connection at script top.', 'duration': 26.319, 'max_score': 23.313, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw23313.jpg'}, {'end': 109.376, 'src': 'embed', 'start': 82.651, 'weight': 0, 'content': [{'end': 90.813, 'text': "I'll show you the script working at developphp.com to render out my testimonials in paginated results instead of one giant list.", 'start': 82.651, 'duration': 8.162}, {'end': 96.354, 'text': 'Now we run the query against the database, and this is a MySQL I based query.', 'start': 91.473, 'duration': 4.881}, {'end': 102.955, 'text': 'so we put in the connection variable first and the second parameter that we put in is our SQL syntax,', 'start': 96.354, 'duration': 6.601}, {'end': 109.376, 'text': 'which you could take all of this SQL syntax right here and just put it right there if you want, but I like separating mine out like that.', 'start': 102.955, 'duration': 6.421}], 'summary': 'Demonstrating paginated testimonials using mysql query at developphp.com.', 'duration': 26.725, 'max_score': 82.651, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw82651.jpg'}, {'end': 166.65, 'src': 'embed', 'start': 141.567, 'weight': 2, 'content': [{'end': 149.211, 'text': "so in my database I have an enum field called approved and it's set to zero at first and then when I approve the Testimonial that people write in,", 'start': 141.567, 'duration': 7.644}, {'end': 150.612, 'text': 'then it becomes a one.', 'start': 149.211, 'duration': 1.401}, {'end': 154.374, 'text': "so I just want to make sure that I'm counting only the approved testimonials.", 'start': 150.612, 'duration': 3.762}, {'end': 155.736, 'text': 'Now, in the very next line,', 'start': 154.554, 'duration': 1.182}, {'end': 166.65, 'text': "we're going to type ourselves a comment in that says here we have the total row count by specifying the row variable here and then accessing its first and only index,", 'start': 155.736, 'duration': 10.914}], 'summary': "Database has enum field 'approved' initially set to 0, changes to 1 after approval. counting only approved testimonials.", 'duration': 25.083, 'max_score': 141.567, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw141567.jpg'}], 'start': 0.25, 'title': 'Php pagination tutorial', 'summary': 'Covers the process of setting up a php script for paginating data from a mysql database, including establishing a mysql-i based connection, querying the database, and accessing the query result set.', 'chapters': [{'end': 155.736, 'start': 0.25, 'title': 'Php pagination tutorial', 'summary': 'Covers the process of setting up a php script for paginating data from a mysql database, including establishing a mysql-i based connection, querying the database, and accessing the query result set.', 'duration': 155.486, 'highlights': ['The tutorial begins with setting up the basic structure of an HTML5 web document and establishing a MySQL-I based connection to the database.', 'The script showcases the process of querying a MySQL database for paginated data and accessing the query result set.', "The importance of ensuring only approved testimonials are counted is emphasized, with the enum field 'approved' set to zero initially and updated to one upon approval."]}], 'duration': 155.486, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw250.jpg', 'highlights': ['The script showcases the process of querying a MySQL database for paginated data and accessing the query result set.', 'The tutorial begins with setting up the basic structure of an HTML5 web document and establishing a MySQL-I based connection to the database.', "The importance of ensuring only approved testimonials are counted is emphasized, with the enum field 'approved' set to zero initially and updated to one upon approval."]}, {'end': 278.87, 'segs': [{'end': 202.643, 'src': 'embed', 'start': 176.961, 'weight': 0, 'content': [{'end': 183.107, 'text': 'So you access the first one and that gives you the total count of rows from this testimonials table.', 'start': 176.961, 'duration': 6.146}, {'end': 185.069, 'text': 'So here we have the total row count.', 'start': 183.347, 'duration': 1.722}, {'end': 192.395, 'text': "Now in the very next line we're going to type in another comment that says this is the number of results we want displayed per page.", 'start': 185.249, 'duration': 7.146}, {'end': 194.177, 'text': "So let's create that variable now.", 'start': 192.615, 'duration': 1.562}, {'end': 202.643, 'text': "We're going to name that variable page rows and we're going to make it equal to 10 because I want 10 items to be listed on each page.", 'start': 194.337, 'duration': 8.306}], 'summary': 'Accessed table gives total row count, set 10 items per page', 'duration': 25.682, 'max_score': 176.961, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw176961.jpg'}, {'end': 266.914, 'src': 'embed', 'start': 236.98, 'weight': 1, 'content': [{'end': 244.524, 'text': 'So we name the variable last and we run the seal function, which is a math function in PHP, and we say rows,', 'start': 236.98, 'duration': 7.544}, {'end': 250.527, 'text': 'which is the full rows count from the database, divided by 10, basically or whatever.', 'start': 244.524, 'duration': 6.003}, {'end': 251.368, 'text': 'you made this number.', 'start': 250.527, 'duration': 0.841}, {'end': 257.63, 'text': 'And that gives you, that little calculation result gives you the last page variable.', 'start': 252.088, 'duration': 5.542}, {'end': 266.914, 'text': 'So if your result set from your database is paged out into 88 different pages, then this last variable will be 88.', 'start': 257.93, 'duration': 8.984}], 'summary': 'Using php math function to calculate last page variable based on rows count and pagination factor.', 'duration': 29.934, 'max_score': 236.98, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw236980.jpg'}], 'start': 155.736, 'title': 'Php pagination and row count', 'summary': 'Discusses obtaining the total row count, setting the number of results per page, and calculating the last page number in php, emphasizing the use of the php seal function for rounding up numbers.', 'chapters': [{'end': 278.87, 'start': 155.736, 'title': 'Php pagination and row count', 'summary': 'Discusses obtaining the total row count from a database table, setting the number of results displayed per page, and calculating the page number of the last page based on the row count, with an emphasis on the php seal function for rounding up numbers.', 'duration': 123.134, 'highlights': ['Obtaining the total row count from a database table', 'Setting the number of results displayed per page', 'Calculating the page number of the last page based on the row count']}], 'duration': 123.134, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw155736.jpg', 'highlights': ['Obtaining the total row count from a database table', 'Calculating the page number of the last page based on the row count', 'Setting the number of results displayed per page']}, {'end': 469.857, 'segs': [{'end': 309.155, 'src': 'embed', 'start': 278.931, 'weight': 0, 'content': [{'end': 282.132, 'text': "That's the only reason we're running SEAL on this little equation here.", 'start': 278.931, 'duration': 3.201}, {'end': 287.975, 'text': 'Now since some of the variables are going to be in the URL, that means people can manipulate the variables.', 'start': 282.512, 'duration': 5.463}, {'end': 294.44, 'text': "And so we're going to put in another comment that says, this makes sure last, cannot be less than 1.", 'start': 288.416, 'duration': 6.024}, {'end': 301.767, 'text': "So let's put a little if condition right here just to make sure that last can never be less than 1 before our script processes that variable.", 'start': 294.44, 'duration': 7.327}, {'end': 309.155, 'text': 'So this if condition reads if last is less than 1 then we make last equal to 1.', 'start': 301.988, 'duration': 7.167}], 'summary': 'Seal algorithm ensures last variable cannot be less than 1', 'duration': 30.224, 'max_score': 278.931, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw278931.jpg'}, {'end': 359.649, 'src': 'embed', 'start': 337.159, 'weight': 2, 'content': [{'end': 345.184, 'text': "So, basically, you establish pageNum variable as 1 here, and then we're going to see if there's a get variable set of pn,", 'start': 337.159, 'duration': 8.025}, {'end': 348.466, 'text': "because that's what we're going to name our variable when we send it through the URL.", 'start': 345.184, 'duration': 3.282}, {'end': 357.708, 'text': "So we say if isSet the get variable of PN, then we're gonna gather up that get variable of PN and it's gonna represent a number,", 'start': 348.882, 'duration': 8.826}, {'end': 359.649, 'text': 'whichever page the user wants to go to.', 'start': 357.708, 'duration': 1.941}], 'summary': 'Initialize pagenum as 1, check if pn get variable is set, and gather the value as the page number.', 'duration': 22.49, 'max_score': 337.159, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw337159.jpg'}, {'end': 429.515, 'src': 'embed', 'start': 382.201, 'weight': 3, 'content': [{'end': 390.717, 'text': 'But if it is set in the URL, then pageNum variable becomes whatever this PN URL variable is in the address bar.', 'start': 382.201, 'duration': 8.516}, {'end': 395.167, 'text': 'after you go through the tutorial, you can go ahead and remove all of these comment lines,', 'start': 391.266, 'duration': 3.901}, {'end': 398.968, 'text': "and that'll make your script a lot slimmer and make it look a lot smaller.", 'start': 395.167, 'duration': 3.801}, {'end': 404.449, 'text': 'but just keep the comments there until you fully understand each line or each segment of code.', 'start': 398.968, 'duration': 5.481}, {'end': 405.869, 'text': 'okay, so right,', 'start': 404.449, 'duration': 1.42}, {'end': 415.931, 'text': "under all of that we're going to place in another comment that says this makes sure the page number isn't below one or more than our last page variable.", 'start': 405.869, 'duration': 10.062}, {'end': 424.114, 'text': "we don't want page num to ever be below a one or more than the last page, and this little condition will handle that.", 'start': 415.931, 'duration': 8.183}, {'end': 429.515, 'text': 'we say, if the page num is less than one, then the page num is equal to one.', 'start': 424.114, 'duration': 5.401}], 'summary': "Tutorial recommends removing comments for a slimmer script. it ensures page number isn't below one or more than the last page.", 'duration': 47.314, 'max_score': 382.201, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw382201.jpg'}, {'end': 479.411, 'src': 'embed', 'start': 451.024, 'weight': 1, 'content': [{'end': 460.39, 'text': 'so basically, if you have 88 pages of results and somebody changes that 88 the last page in the URL address bar, maybe they change it to a 92.', 'start': 451.024, 'duration': 9.366}, {'end': 469.857, 'text': "you just want to make sure that that doesn't process in your script and you change page num from 92 that they input to 88.", 'start': 460.39, 'duration': 9.467}, {'end': 479.411, 'text': "so this if condition, or this if, and else if condition, just make sure that the page number isn't below one or more than your last page.", 'start': 469.857, 'duration': 9.554}], 'summary': "Ensure page number doesn't exceed 88 in script", 'duration': 28.387, 'max_score': 451.024, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw451024.jpg'}], 'start': 278.931, 'title': 'Url and page number handling in script', 'summary': "Discusses handling url variables in a script, setting conditions to ensure 'last' is never less than 1, establishing the 'pagenum' variable, and filtering 'pagenum' to accept numbers from the url variable 'pn'. it also addresses preventing the url address bar from being manipulated to an invalid page number.", 'chapters': [{'end': 405.869, 'start': 278.931, 'title': 'Url variable handling in script', 'summary': "Discusses handling url variables in a script, including setting conditions to ensure 'last' is never less than 1, establishing the 'pagenum' variable, and filtering 'pagenum' to only accept numbers from the url variable 'pn'.", 'duration': 126.938, 'highlights': ["The if condition ensures that the variable 'last' can never be less than 1, providing a safeguard against manipulation of the variable in the URL.", "The script establishes the 'pageNum' variable as 1 by default and then checks if a 'pn' variable is set in the URL to represent the page number, filtering it to accept only numbers.", 'It is recommended to keep the comments in the script until full understanding is achieved, and removing them after that will make the script slimmer.']}, {'end': 469.857, 'start': 405.869, 'title': 'Handling page number limits', 'summary': 'Discusses handling page number limits in a script, ensuring that the page number is not below one or higher than the last page variable, preventing the url address bar from being manipulated to an invalid page number.', 'duration': 63.988, 'highlights': ['If the page num is less than one, then the page num is equal to one.', 'If the page num is greater than the last page number, then page num is going to be equal to last.', 'Preventing the URL address bar from being manipulated to an invalid page number is crucial for script functionality.']}], 'duration': 190.926, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw278931.jpg', 'highlights': ["The if condition ensures that the variable 'last' can never be less than 1, providing a safeguard against manipulation of the variable in the URL.", 'Preventing the URL address bar from being manipulated to an invalid page number is crucial for script functionality.', "The script establishes the 'pageNum' variable as 1 by default and then checks if a 'pn' variable is set in the URL to represent the page number, filtering it to accept only numbers.", 'If the page num is greater than the last page number, then page num is going to be equal to last.', 'If the page num is less than one, then the page num is equal to one.', 'It is recommended to keep the comments in the script until full understanding is achieved, and removing them after that will make the script slimmer.']}, {'end': 629.571, 'segs': [{'end': 558.675, 'src': 'embed', 'start': 514.809, 'weight': 0, 'content': [{'end': 520.913, 'text': "Do you understand? So if you're on page 3, you don't want to gather all of the first rows in the database.", 'start': 514.809, 'duration': 6.104}, {'end': 525.655, 'text': 'You want to make sure you gather a result set that corresponds to that page 3.', 'start': 520.933, 'duration': 4.722}, {'end': 530.638, 'text': 'So you really have to understand the limit syntax For SQL.', 'start': 525.655, 'duration': 4.983}, {'end': 536.582, 'text': "If you don't understand the limit and what limit does in an SQL query then you're not going to understand this tutorial.", 'start': 530.898, 'duration': 5.684}, {'end': 544.147, 'text': 'So what you want to do is make sure you look into and make sure that you understand what limit does in SQL queries.', 'start': 537.162, 'duration': 6.985}, {'end': 547.709, 'text': "It just limits how many you're grabbing out of the database.", 'start': 544.527, 'duration': 3.182}, {'end': 550.27, 'text': 'Now let me put in the next comment and the query.', 'start': 548.109, 'duration': 2.161}, {'end': 553.072, 'text': 'So this next comment says, this is your query again.', 'start': 550.47, 'duration': 2.602}, {'end': 558.675, 'text': 'It is for grabbing just one page worth of rows by applying the limit variable.', 'start': 553.092, 'duration': 5.583}], 'summary': 'Understanding sql limit syntax is crucial for grabbing specific result sets for pagination.', 'duration': 43.866, 'max_score': 514.809, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw514808.jpg'}, {'end': 603.879, 'src': 'heatmap', 'start': 559.055, 'weight': 0.751, 'content': [{'end': 567.239, 'text': 'So I say select ID, first name, last name, the date made from my testimonials table where approved equals one.', 'start': 559.055, 'duration': 8.184}, {'end': 571.362, 'text': "And I'm going to order all those results by ID descending.", 'start': 567.359, 'duration': 4.003}, {'end': 576.167, 'text': 'and then my limit syntax goes on the very end of the query.', 'start': 572.302, 'duration': 3.865}, {'end': 579.031, 'text': 'You can see what my limit syntax is made up of.', 'start': 576.468, 'duration': 2.563}, {'end': 583.276, 'text': "Limit then space and it's going to be two numbers.", 'start': 579.411, 'duration': 3.865}, {'end': 595.215, 'text': 'The first number is made by taking pageNum minus one and multiplying it by page rows, basically 10, because we made page rows 10 up here.', 'start': 584.117, 'duration': 11.098}, {'end': 603.879, 'text': 'Then the next number for your limit syntax is going to be 10, or whatever page rows, whatever value you made the page rows variable.', 'start': 595.575, 'duration': 8.304}], 'summary': 'Retrieve data from testimonials table with approved equals one, order by id descending, and apply pagination with 10 rows per page.', 'duration': 44.824, 'max_score': 559.055, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw559055.jpg'}], 'start': 469.857, 'title': 'Sql query limit syntax', 'summary': 'Explains the importance of understanding the limit syntax in sql queries, enabling the gathering of a specific page result set. it includes an example of applying the limit variable to fetch one page worth of rows.', 'chapters': [{'end': 629.571, 'start': 469.857, 'title': 'Sql query limit syntax tutorial', 'summary': 'Explains the importance of understanding the limit syntax in sql queries for gathering a result set corresponding to a specific page, with an example of applying the limit variable to a query fetching one page worth of rows.', 'duration': 159.714, 'highlights': ['The chapter emphasizes the significance of understanding the limit syntax in SQL queries for gathering a result set corresponding to a specific page.', 'Explanation of applying the limit variable to a query fetching one page worth of rows.', 'Importance of comprehending the limit syntax in SQL queries for understanding the tutorial.']}], 'duration': 159.714, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw469857.jpg', 'highlights': ['The chapter emphasizes the significance of understanding the limit syntax in SQL queries for gathering a result set corresponding to a specific page.', 'Explanation of applying the limit variable to a query fetching one page worth of rows.', 'Importance of comprehending the limit syntax in SQL queries for understanding the tutorial.']}, {'end': 754.878, 'segs': [{'end': 669.201, 'src': 'embed', 'start': 647.116, 'weight': 0, 'content': [{'end': 655.818, 'text': "So the first text line one says testimonials and then you're going to put the number of rows, the full amount of rows from the database.", 'start': 647.116, 'duration': 8.702}, {'end': 662.019, 'text': 'So if your database has a thousand testimonials in it, that number will be right here.', 'start': 655.858, 'duration': 6.161}, {'end': 669.201, 'text': "And then that would mean since we're making ten rows come out per page, that means you'll have a hundred pages.", 'start': 662.499, 'duration': 6.702}], 'summary': 'A database with 1000 testimonials will generate 100 pages with 10 rows each.', 'duration': 22.085, 'max_score': 647.116, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw647116.jpg'}, {'end': 730.483, 'src': 'embed', 'start': 692.419, 'weight': 1, 'content': [{'end': 694.28, 'text': "And that's going to be equal to nothing.", 'start': 692.419, 'duration': 1.861}, {'end': 696.022, 'text': "when it's established.", 'start': 694.881, 'duration': 1.141}, {'end': 698.603, 'text': 'so we have a variable ready called pagination controls,', 'start': 696.022, 'duration': 2.581}, {'end': 708.59, 'text': "and what we're going to do is add to that pagination controls variable to make all of the clickable numbers and the previous and next buttons and all that stuff.", 'start': 698.603, 'duration': 9.987}, {'end': 710.751, 'text': "now what i'm going to do is just make everything simple.", 'start': 708.59, 'duration': 2.161}, {'end': 715.014, 'text': 'links pretty much how you would see in google style results.', 'start': 710.751, 'duration': 4.263}, {'end': 716.995, 'text': 'when you go to google and you search,', 'start': 715.014, 'duration': 1.981}, {'end': 722.699, 'text': "you can look at their pagination at the bottom And we're going to make that style of pagination or very similar to that.", 'start': 716.995, 'duration': 5.704}, {'end': 728.722, 'text': "Now under that, we're going to put in another comment that says, if there's more than one page worth of results.", 'start': 723.059, 'duration': 5.663}, {'end': 730.483, 'text': "So let's put in an if condition here.", 'start': 729.042, 'duration': 1.441}], 'summary': 'Adding pagination controls for clickable numbers and next/previous buttons, similar to google style results.', 'duration': 38.064, 'max_score': 692.419, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw692419.jpg'}], 'start': 629.591, 'title': 'Creating pagination controls', 'summary': 'Discusses creating pagination controls for a testimonials page, displaying page information for up to 100 pages with 10 testimonials per page, and establishing pagination controls based on the number of pages and a google-style pagination format.', 'chapters': [{'end': 754.878, 'start': 629.591, 'title': 'Pagination controls and page information', 'summary': 'Discusses creating pagination controls and displaying page information for a testimonials page, with a potential of displaying 100 pages with 10 testimonials per page, and establishing pagination controls based on the number of pages and a google-style pagination format.', 'duration': 125.287, 'highlights': ['Creating pagination controls and displaying page information', 'Potential of displaying 100 pages with 10 testimonials per page', 'Establishing pagination controls based on the number of pages and a Google-style pagination format']}], 'duration': 125.287, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw629591.jpg', 'highlights': ['Potential of displaying 100 pages with 10 testimonials per page', 'Establishing pagination controls based on the number of pages and a Google-style pagination format', 'Creating pagination controls and displaying page information']}, {'end': 1098.231, 'segs': [{'end': 778.492, 'src': 'embed', 'start': 755.338, 'weight': 1, 'content': [{'end': 764.103, 'text': "So you really don't have to give them next and previous buttons or little links for numbers of pages to click because there's only one page.", 'start': 755.338, 'duration': 8.765}, {'end': 769.387, 'text': "So within this if condition is where we're going to build up this pagination controls variable.", 'start': 764.444, 'duration': 4.943}, {'end': 775.61, 'text': "Because only if there's more than one page worth of results are we going to render those little things at the bottom.", 'start': 769.827, 'duration': 5.783}, {'end': 778.492, 'text': "Okay, now I'm going to put in a little multi-line comment.", 'start': 775.991, 'duration': 2.501}], 'summary': "Pagination controls are only rendered if there's more than one page worth of results.", 'duration': 23.154, 'max_score': 755.338, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw755338.jpg'}, {'end': 921.702, 'src': 'heatmap', 'start': 841.465, 'weight': 0.989, 'content': [{'end': 850.747, 'text': 'and also the first little bit of Rendering that you want in your pagination controls is going to be a link that is set to the server self.', 'start': 841.465, 'duration': 9.282}, {'end': 853.108, 'text': "So whichever page you're on, it doesn't matter.", 'start': 850.807, 'duration': 2.301}, {'end': 854.949, 'text': "You don't have to put the page name there.", 'start': 853.128, 'duration': 1.821}, {'end': 860.052, 'text': 'But you want to make sure you append to the URL the page number variable.', 'start': 855.49, 'duration': 4.562}, {'end': 861.753, 'text': "That's the get variable.", 'start': 860.392, 'duration': 1.361}, {'end': 863.514, 'text': 'The URL variable.', 'start': 862.233, 'duration': 1.281}, {'end': 869.148, 'text': 'And you want to make sure that that is equal to the previous variable.', 'start': 864.575, 'duration': 4.573}, {'end': 874.734, 'text': "remember, like I said, if you're on page seven, you want to make sure that there's a link that says previous.", 'start': 869.148, 'duration': 5.586}, {'end': 876.893, 'text': "So that's the label in the link.", 'start': 875.572, 'duration': 1.321}, {'end': 882.355, 'text': "it's going to be the word previous and it's going to be going to whatever the previous page is.", 'start': 876.893, 'duration': 5.462}, {'end': 886.296, 'text': "Now we're going to place ourselves a comment under that.", 'start': 882.755, 'duration': 3.541}, {'end': 892.699, 'text': 'that says render clickable number links that should appear on the left of the target page number.', 'start': 886.296, 'duration': 6.403}, {'end': 894.939, 'text': "So here we're going to use a for loop for that.", 'start': 893.079, 'duration': 1.86}, {'end': 898.921, 'text': "So with the for loop you're going to feed your for loop three parameters.", 'start': 895.159, 'duration': 3.762}, {'end': 902.404, 'text': 'The first parameter is what you want to start the index at.', 'start': 899.301, 'duration': 3.103}, {'end': 905.847, 'text': 'So I named the variable i like we usually do in for loops.', 'start': 902.464, 'duration': 3.383}, {'end': 909.591, 'text': "And that's going to be equal to page number minus 4.", 'start': 906.108, 'duration': 3.483}, {'end': 916.838, 'text': "So if you're on page number 7, this i variable is going to equal 7 minus 4 which is what? 3.", 'start': 909.591, 'duration': 7.247}, {'end': 921.702, 'text': 'So in that case if the user happens to be on page 7, This will represent a 3.', 'start': 916.838, 'duration': 4.864}], 'summary': 'Rendering pagination controls with previous link and clickable number links using a for loop.', 'duration': 80.237, 'max_score': 841.465, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw841465.jpg'}, {'end': 1098.231, 'src': 'embed', 'start': 1060.614, 'weight': 0, 'content': [{'end': 1067.075, 'text': "then you're going to put in another comment that says render the clickable number links that should appear on the right of the target page number.", 'start': 1060.614, 'duration': 6.461}, {'end': 1069.275, 'text': "We're going to use a for loop for that as well.", 'start': 1067.335, 'duration': 1.94}, {'end': 1072.456, 'text': "Now let's pop that loop into place and I'll explain it real quick.", 'start': 1069.556, 'duration': 2.9}, {'end': 1077.557, 'text': 'And you pretty much have to understand how for loops work to really grasp the whole script.', 'start': 1072.816, 'duration': 4.741}, {'end': 1081.538, 'text': "And once you understand how for loops work, which they're very simple in our case,", 'start': 1077.937, 'duration': 3.601}, {'end': 1086.2, 'text': 'they might look a little complicated here because we have a lot of different code at play.', 'start': 1081.538, 'duration': 4.662}, {'end': 1089.723, 'text': "but if you look at a basic for loop, it's very simple to comprehend.", 'start': 1086.2, 'duration': 3.523}, {'end': 1095.208, 'text': "so i would recommend, if you don't understand how for loops run, to research for loops in php.", 'start': 1089.723, 'duration': 5.485}, {'end': 1098.231, 'text': 'that way you can see it at its most basic level.', 'start': 1095.208, 'duration': 3.023}], 'summary': 'Using for loops to render clickable number links for target page numbers in php.', 'duration': 37.617, 'max_score': 1060.614, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw1060614.jpg'}], 'start': 755.338, 'title': 'Pagination controls and code explanation', 'summary': 'Discusses building pagination controls and rendering page links, including code explanation, specific examples, and recommendations.', 'chapters': [{'end': 960.126, 'start': 755.338, 'title': 'Pagination controls and page rendering', 'summary': 'Discusses the process of building pagination controls for a single page, including the conditions for rendering previous and first page links, and the implementation of clickable number links using a for loop.', 'duration': 204.788, 'highlights': ['The chapter discusses the process of building pagination controls for a single page', 'Conditions for rendering previous and first page links', 'Implementation of clickable number links using a for loop']}, {'end': 1098.231, 'start': 960.126, 'title': 'Pagination control code explanation', 'summary': 'Explains the code for pagination controls, including the rendering of the left and right side of the target page number, with specific examples and recommendations.', 'duration': 138.105, 'highlights': ['Explanation of Pagination Controls Code', 'Example of Pagination Controls Implementation', 'Recommendation to Understand For Loops']}], 'duration': 342.893, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw755338.jpg', 'highlights': ['Implementation of clickable number links using a for loop', 'Conditions for rendering previous and first page links', 'Explanation of Pagination Controls Code', 'Example of Pagination Controls Implementation', 'Recommendation to Understand For Loops', 'The chapter discusses the process of building pagination controls for a single page']}, {'end': 1405.012, 'segs': [{'end': 1234.328, 'src': 'embed', 'start': 1212.35, 'weight': 0, 'content': [{'end': 1222.698, 'text': "this little if condition helps you break the for loop from running any further to render numbers out there that don't correspond to any pages that exist in your pagination.", 'start': 1212.35, 'duration': 10.348}, {'end': 1228.543, 'text': 'Now remember, in this condition we said if the page num is greater than one, then, and only then,', 'start': 1223.299, 'duration': 5.244}, {'end': 1234.328, 'text': "we're going to put a previous link and little numbers going back to previous pages.", 'start': 1228.543, 'duration': 5.785}], 'summary': 'If page num > 1, a previous link and numbers for previous pages will be rendered.', 'duration': 21.978, 'max_score': 1212.35, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw1212350.jpg'}, {'end': 1276.67, 'src': 'embed', 'start': 1253.588, 'weight': 4, 'content': [{'end': 1261.278, 'text': 'the little next word, which is a feature that you might want in your pagination, is to have the word next after all those little numbers,', 'start': 1253.588, 'duration': 7.69}, {'end': 1265.503, 'text': 'just the same way you have the word previous before all the little numbers.', 'start': 1261.278, 'duration': 4.225}, {'end': 1272.788, 'text': "So if the page that they're on is not equal to the last page, then you definitely want to have the next button.", 'start': 1266.044, 'duration': 6.744}, {'end': 1276.67, 'text': "But if they are on the last page, you don't render anything.", 'start': 1273.128, 'duration': 3.542}], 'summary': "Implement 'next' word feature for pagination with last page check.", 'duration': 23.082, 'max_score': 1253.588, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw1253588.jpg'}, {'end': 1358.854, 'src': 'heatmap', 'start': 1300.786, 'weight': 2, 'content': [{'end': 1309.315, 'text': "Now after all of that you go down one line and make sure you're outside of your if condition that you said if last does not equal 1.", 'start': 1300.786, 'duration': 8.529}, {'end': 1310.957, 'text': 'You see where that ends right here.', 'start': 1309.315, 'duration': 1.642}, {'end': 1315.302, 'text': "You go outside of that and here's where you're going to render your while loop.", 'start': 1311.277, 'duration': 4.025}, {'end': 1318.723, 'text': 'like you normally do for a MySQL result set.', 'start': 1315.802, 'duration': 2.921}, {'end': 1324.844, 'text': "What we're going to do is first establish a variable called list because that variable is going to be echoed out to the page.", 'start': 1319.063, 'duration': 5.781}, {'end': 1331.666, 'text': "So we're going to compound that variable with all the data that we need for each little testimonial within this while loop.", 'start': 1325.364, 'duration': 6.302}, {'end': 1338.207, 'text': 'So basically you run your normal while loop here for this last query that was made right here.', 'start': 1332.146, 'duration': 6.061}, {'end': 1348.468, 'text': 'So this while loop will grab all of the rows that you need for that specific page that the user is requesting to see, those 10 items.', 'start': 1340.523, 'duration': 7.945}, {'end': 1352.43, 'text': "So in the while loop, I'm gonna grab the ID out of the database row.", 'start': 1348.868, 'duration': 3.562}, {'end': 1358.854, 'text': "I'm gonna grab the first name, the person's last name, the date that the testimonial was made,", 'start': 1352.851, 'duration': 6.003}], 'summary': 'Rendering a while loop to display 10 items from a mysql result set, grabbing id, first name, last name, and testimonial date.', 'duration': 58.068, 'max_score': 1300.786, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw1300786.jpg'}, {'end': 1405.012, 'src': 'embed', 'start': 1340.523, 'weight': 1, 'content': [{'end': 1348.468, 'text': 'So this while loop will grab all of the rows that you need for that specific page that the user is requesting to see, those 10 items.', 'start': 1340.523, 'duration': 7.945}, {'end': 1352.43, 'text': "So in the while loop, I'm gonna grab the ID out of the database row.", 'start': 1348.868, 'duration': 3.562}, {'end': 1358.854, 'text': "I'm gonna grab the first name, the person's last name, the date that the testimonial was made,", 'start': 1352.851, 'duration': 6.003}, {'end': 1363.857, 'text': "and then I'm just going to put the date made into a more human, readable format.", 'start': 1358.854, 'duration': 5.003}, {'end': 1369.219, 'text': "and then I'm going to make my little list which each item in the list is going to be in a p tag,", 'start': 1363.857, 'duration': 5.362}, {'end': 1379.496, 'text': 'because I want them separated a little bit down the page And each one is going to have a link to the proper testimonial which will render on testimonial.php.', 'start': 1369.219, 'duration': 10.277}, {'end': 1383.698, 'text': 'And the ID URL variable will be sunk in right there.', 'start': 1379.996, 'duration': 3.702}, {'end': 1386.5, 'text': "And I'm going to show you guys all of this working in just a moment.", 'start': 1384.039, 'duration': 2.461}, {'end': 1391.784, 'text': "So the label for that link is going to be the person's first name, last name, and the word testimonial.", 'start': 1386.72, 'duration': 5.064}, {'end': 1393.825, 'text': 'Then the link closes right there.', 'start': 1392.164, 'duration': 1.661}, {'end': 1398.488, 'text': "And then I'll have some text that just says, click the link to view the testimonial.", 'start': 1393.845, 'duration': 4.643}, {'end': 1402.071, 'text': 'Or I could actually put some of the testimonial that they wrote.', 'start': 1398.809, 'duration': 3.262}, {'end': 1403.091, 'text': 'in here.', 'start': 1402.751, 'duration': 0.34}, {'end': 1405.012, 'text': 'I can put a few lines in here if I want.', 'start': 1403.131, 'duration': 1.881}], 'summary': 'A loop retrieves 10 rows from the database, displaying testimonials with links to individual pages.', 'duration': 64.489, 'max_score': 1340.523, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw1340523.jpg'}], 'start': 1098.231, 'title': 'Pagination and testimonial rendering logic', 'summary': 'Explains the logic behind creating pagination controls using a for loop with a condition to limit execution and covers rendering testimonials using a php while loop, including data fetching, formatting, and iteration process.', 'chapters': [{'end': 1300.246, 'start': 1098.231, 'title': 'Pagination control logic', 'summary': "Explains the logic behind creating pagination controls, using a for loop to generate page numbers with a condition to limit the loop's execution and determine when to display 'previous' and 'next' links based on the user's current page.", 'duration': 202.015, 'highlights': ['Using a for loop to generate page numbers', 'Condition to limit the loop execution', "Determining when to display 'previous' and 'next' links"]}, {'end': 1405.012, 'start': 1300.786, 'title': 'Php while loop for rendering testimonials', 'summary': 'Covers the process of rendering testimonials using a while loop in php, including fetching data from a mysql result set and formatting it for display, demonstrating the iteration process and the creation of a link to view each testimonial.', 'duration': 104.226, 'highlights': ['The while loop is used to fetch all the rows needed for a specific page, typically 10 items, from the last query made.', 'The data fetched within the while loop includes the ID, first name, last name, and date of the testimonial, which is then formatted into a more human-readable form.', 'Each testimonial is displayed as a separate item in a list with a link to view the full testimonial on testimonial.php, along with additional text or excerpt from the testimonial.', "The label for the link includes the person's first name, last name, and the word 'testimonial'."]}], 'duration': 306.781, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw1098231.jpg', 'highlights': ['Using a for loop to generate page numbers', 'The while loop is used to fetch all the rows needed for a specific page, typically 10 items, from the last query made', 'Condition to limit the loop execution', 'The data fetched within the while loop includes the ID, first name, last name, and date of the testimonial, which is then formatted into a more human-readable form', "Determining when to display 'previous' and 'next' links", 'Each testimonial is displayed as a separate item in a list with a link to view the full testimonial on testimonial.php, along with additional text or excerpt from the testimonial', "The label for the link includes the person's first name, last name, and the word 'testimonial'"]}, {'end': 1871.352, 'segs': [{'end': 1454.28, 'src': 'embed', 'start': 1429.753, 'weight': 1, 'content': [{'end': 1437.135, 'text': "So we close our MySQL database connection here because we don't need to be connected to the database any further past that point.", 'start': 1429.753, 'duration': 7.382}, {'end': 1442.136, 'text': "Now let's go down into our HTML where you can see we just have the bare bones still.", 'start': 1437.655, 'duration': 4.481}, {'end': 1443.617, 'text': "There's nothing in our body tag.", 'start': 1442.156, 'duration': 1.461}, {'end': 1445.257, 'text': "There's nothing in our style tag.", 'start': 1443.737, 'duration': 1.52}, {'end': 1450.739, 'text': "So within the body tag, I'm going to place the following code, which is a div element.", 'start': 1445.477, 'duration': 5.262}, {'end': 1454.28, 'text': "And in that div element, I'm going to have an H2 heading.", 'start': 1451.199, 'duration': 3.081}], 'summary': 'Closing mysql connection, adding div element with h2 heading to html.', 'duration': 24.527, 'max_score': 1429.753, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw1429753.jpg'}, {'end': 1605.276, 'src': 'embed', 'start': 1581.202, 'weight': 0, 'content': [{'end': 1592.068, 'text': 'this is, um, the text line one, testimonials, 105 total paged, and then text line two says page one of 11 pages.', 'start': 1581.202, 'duration': 10.866}, {'end': 1597.171, 'text': 'then you can see i have 10 different testimonials that i can click on and go read.', 'start': 1592.068, 'duration': 5.103}, {'end': 1602.174, 'text': 'if i click on this one, you can see that i have gone to that testimonial page.', 'start': 1597.171, 'duration': 5.003}, {'end': 1605.276, 'text': "it's testimonial.php, with an id of 210..", 'start': 1602.174, 'duration': 3.102}], 'summary': 'Transcript: 105 total testimonials, with 11 pages available for viewing.', 'duration': 24.074, 'max_score': 1581.202, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw1581202.jpg'}, {'end': 1847.798, 'src': 'embed', 'start': 1818.163, 'weight': 2, 'content': [{'end': 1823.005, 'text': 'because PHP and JavaScript in their raw form are simple enough for children to use.', 'start': 1818.163, 'duration': 4.842}, {'end': 1830.048, 'text': "The only reason we use frameworks is when we don't know how to program something and we need to accomplish that task.", 'start': 1823.605, 'duration': 6.443}, {'end': 1837.871, 'text': 'But Ajax based pagination like Facebook and Twitter use is not very hard to wrap your head around and I can show you how to do it.', 'start': 1830.308, 'duration': 7.563}, {'end': 1839.552, 'text': 'without any frameworks.', 'start': 1838.311, 'duration': 1.241}, {'end': 1841.573, 'text': "you won't have to use jQuery.", 'start': 1839.552, 'duration': 2.021}, {'end': 1847.798, 'text': "you won't have to use any PHP frameworks like CodeIgniter or whatever people are using.", 'start': 1841.573, 'duration': 6.225}], 'summary': 'Php and javascript can be used without frameworks for tasks like ajax pagination, as demonstrated by facebook and twitter.', 'duration': 29.635, 'max_score': 1818.163, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw1818163.jpg'}], 'start': 1405.052, 'title': 'Html rendering, database closure, php pagination, and css styling', 'summary': 'Covers rendering html elements, closing mysql database connection, adding div, h2, and paragraph elements, while emphasizing resource-saving database closure. it also discusses php pagination, live server testing, and the possibility of ajax-based pagination without frameworks.', 'chapters': [{'end': 1492.99, 'start': 1405.052, 'title': 'Html rendering and database connection closure', 'summary': 'Discusses rendering html elements and closing the mysql database connection, with a focus on adding div elements, h2 headings, and paragraph elements to the html body, as well as the importance of closing the database connection to save resources.', 'duration': 87.938, 'highlights': ['Closing the MySQL database connection is crucial to free up resources and improve performance.', 'Adding div elements, h2 headings, and paragraph elements to the HTML body for rendering the content.']}, {'end': 1871.352, 'start': 1492.99, 'title': 'Php pagination and css styling', 'summary': 'Explains the implementation of pagination with php, including a demonstration of live server testing, and the potential for using the same logic for ajax-based pagination without frameworks.', 'duration': 378.362, 'highlights': ['The chapter demonstrates the implementation of pagination with PHP, including live server testing, resulting in 105 total paged testimonials with 11 pages.', 'The transcript suggests the potential for using the same logic for AJAX-based pagination without frameworks, emphasizing the simplicity and ease of implementation with PHP and JavaScript in their raw form.', 'The speaker offers to create a tutorial on AJAX-based pagination without using any frameworks, emphasizing the ability to fully understand and script the process without external libraries.']}], 'duration': 466.3, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T2QFNu_mivw/pics/T2QFNu_mivw1405052.jpg', 'highlights': ['The chapter demonstrates pagination with PHP, resulting in 105 total paged testimonials.', 'Closing the MySQL database connection is crucial for resource-saving and performance improvement.', 'The potential for AJAX-based pagination without frameworks is emphasized, offering simplicity and ease of implementation with PHP and JavaScript.']}], 'highlights': ['The script showcases the process of querying a MySQL database for paginated data and accessing the query result set.', 'The tutorial begins with setting up the basic structure of an HTML5 web document and establishing a MySQL-I based connection to the database.', 'The chapter demonstrates pagination with PHP, resulting in 105 total paged testimonials.', 'Establishing pagination controls based on the number of pages and a Google-style pagination format', "The importance of ensuring only approved testimonials are counted is emphasized, with the enum field 'approved' set to zero initially and updated to one upon approval.", 'Obtaining the total row count from a database table', 'The chapter emphasizes the significance of understanding the limit syntax in SQL queries for gathering a result set corresponding to a specific page.', "The if condition ensures that the variable 'last' can never be less than 1, providing a safeguard against manipulation of the variable in the URL.", 'The while loop is used to fetch all the rows needed for a specific page, typically 10 items, from the last query made', 'The potential for AJAX-based pagination without frameworks is emphasized, offering simplicity and ease of implementation with PHP and JavaScript.']}