Hello, I am creating a site (for practice). It is a site that works like the '9gag.com' where users can see images stored on the page.

So far, I have successfully retrieved and posted image files from the server but I wanted to put on a limit on how many images will be echoed outside.

I have made the condition that when the number of images arrives to 5 it prints out a next button -->> reloades the page -->> then (SUPPOSES TO) continue reading the next images and prints them. So the output would be 5 images per page.

------The problem is that, I can't think of a best approach for the script to read the next file images STARTING FROM the PREVIOUS echoed file ONCE I CLICK THE NEXT BUTTON-------

This is the code that I come up with so far

			include 'thumbs.php';
			function createGallery($pathToThumbs)
				while(($fname=readdir($dir))!==false && $count<=7)
					if($fname!='.' && $fname!='..')
						echo "<hr>";
						echo "<img src='$path'>";
							echo "<button onClick='createGallery'>next</button>"; 
Member Avatar


Personally, I'd use javascript for this.On first page load get php to dump all images into js array.
Using the js array and a counter, print 5 images to a div and increment the counter by 5. On button click, use the counter to retrieve the next 5 (overwrite the div contents) and increment counter by 5 again... etc... etc.

This means you don't have to involve the php/server.