iNko Posted April 12, 2012 Share Posted April 12, 2012 Hi, i have a folder with thumbnails and original big pictures of the thumbnails, i wanna make it so that the max amount of thumbs that can be displayed on one page would be 3 <body> <div id=head></div> <div id=main> <?php include("loadimages.php") ?> //<- here i take all the thumbnails that are in my thumb folder </div> <div id=foot></div> </body> i have 5 thumbnails, it displays all of them in the "main" div, i wanna add an "Next" and "Previous" buttons, i mean, i want it to show only 3 thumbs at one time, once u click "next" it would remove the first 3 thumbs and load the other 2 thumbnails.. heres a pic maybe it will explain better of what im trying to do.. Quote Link to comment https://forums.phpfreaks.com/topic/260797-display-only-x-amount-of-images-per-page/ Share on other sites More sharing options...
Muddy_Funster Posted April 12, 2012 Share Posted April 12, 2012 search the forum or google for "pagination" Quote Link to comment https://forums.phpfreaks.com/topic/260797-display-only-x-amount-of-images-per-page/#findComment-1336658 Share on other sites More sharing options...
litebearer Posted April 12, 2012 Share Posted April 12, 2012 http://www.nstoia.com/sat/disp_pag/ Quote Link to comment https://forums.phpfreaks.com/topic/260797-display-only-x-amount-of-images-per-page/#findComment-1336663 Share on other sites More sharing options...
iNko Posted April 12, 2012 Author Share Posted April 12, 2012 http://www.nstoia.com/sat/disp_pag/ im checking that page but it says "...This example uses (needs) the following files:A database table....", im not using anything like that Quote Link to comment https://forums.phpfreaks.com/topic/260797-display-only-x-amount-of-images-per-page/#findComment-1336666 Share on other sites More sharing options...
litebearer Posted April 12, 2012 Share Posted April 12, 2012 show us loadimages.php if you ARE placing your images in an array, this may help http://hub.lotsofcode.com/php-array-pagination/ Quote Link to comment https://forums.phpfreaks.com/topic/260797-display-only-x-amount-of-images-per-page/#findComment-1336667 Share on other sites More sharing options...
El Chupacodra Posted April 12, 2012 Share Posted April 12, 2012 Pagination is a pain in the ass sometimes but basically what you need is to set variables for current page, number of photos to show, current page offset (if not the first page) etc. Reading some tutorials will give you an idea. In your case it looks like you will access a second php file making it more complicated. The tutorials rarely bring that up but you might have to use get-variables and urlencode/urldecode if there is any criteria that plays part in showing those particular thumbs (whether it's search terms or user or anything else). It's a lot of work and you might get somewhere faster if you try it yourself first and mail us where and when you get stuck. Quote Link to comment https://forums.phpfreaks.com/topic/260797-display-only-x-amount-of-images-per-page/#findComment-1336672 Share on other sites More sharing options...
iNko Posted April 12, 2012 Author Share Posted April 12, 2012 show us loadimages.php if you ARE placing your images in an array, this may help http://hub.lotsofcode.com/php-array-pagination/ this is my loadimages.php: <?php $dir = "uploads/thumbs/watermarkedthumbs/"; $file_display = array ('jpg', 'jpeg', 'png', 'gif'); if (file_exists($dir) == false) { echo 'tt'; } else { $dir_contents = scandir($dir); foreach ($dir_contents as $file) { $file_type = strtolower(end(explode('.', $file))); if ($file !== '.' && $file !== '..' && in_array($file_type, $file_display) == true) { echo '<img style="border:thin solid #FFF;margin-top:10px;margin-left:10px;margin-right:10px" src="', $dir, '/', $file, '" alt="', $file, '" />'; } } } should i try to modify my loadimages.php file with these codes?: foreach (range(1, 100) as $value) { $products[] = array( 'Product' => 'Product '.$value, 'Price' => rand(100, 1000), ); } and if (count($products)) { // Create the pagination object $pagination = new pagination($products, (isset($_GET['page']) ? $_GET['page'] : 1), 15); // Parse through the pagination class $productPages = $pagination->getResults(); // If we have items if (count($productPages) != 0) { // Create the page numbers echo $pageNumbers = '<div class="numbers">'.$pagination->getLinks().'</div>'; // Loop through all the items in the array foreach ($productPages as $productArray) { // Show the information about the item echo '<p><b>'.$productArray['Product'].'</b> £'.$productArray['Price'].'</p>'; } // print out the page numbers beneath the results echo $pageNumbers; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/260797-display-only-x-amount-of-images-per-page/#findComment-1336679 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.