Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
CREATING A DYNAMIC ONLINE GALLERY Finally, you come out of both conditional statements and display “of” followed by the total number of records. 9. Save the page, and reload it in a browser. You still get only the first subset of thumbnails, but you should see the second number change dynamically whenever you alter the value of SHOWMAX. Check your code, if necessary, against gallery_mysqli_07.php, or gallery_pdo_07.php. Navigating through subsets of records As I mentioned in step 3 of the preceding section, the value of the required page is passed to the PHP script through a query string. When the page first loads,. | CREATING A DYNAMIC ONLINE GALLERY Finally you come out of both conditional statements and display of followed by the total number of records. 9. Save the page and reload it in a browser. You still get only the first subset of thumbnails but you should see the second number change dynamically whenever you alter the value of SHOWMAX. Check your code if necessary against gallery_mysqli_07.php or gallery_pdo_07.php. Navigating through subsets of records As I mentioned in step 3 of the preceding section the value of the required page is passed to the PHP script through a query string. When the page first loads there is no query string so the value of curPage is set to 0. Although a query string is generated when you click a thumbnail to display a different image it includes only the filename of the main image so the original subset of thumbnails remains unchanged. To display the next subset you need to create a link that increases the value of curPage by 1. It follows therefore that to return to the previous subset you need another link that reduces the value of curPage by 1. That s simple enough but you also need to make sure that these links are displayed only when there is a valid subset to navigate to. For instance there s no point in displaying a back link on the first page because there isn t a previous subset. Similarly you shouldn t display a forward link on the page that displays the last subset because there s nothing to navigate to. Both issues are easily solved by using conditional statements. There s one final thing that you need to take care of. You must also include the value of the current page in the query string generated when you click a thumbnail. If you fail to do so curPage is automatically set back to 0 and the first set of thumbnails is displayed instead of the current subset. PHP Solution 12-5 Creating the navigation links This PHP solution shows how to create the navigation links to page back and forth through each subset of records. Continue .