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
<?php
include 'thumbs.php';
function createGallery($pathToThumbs)
{
$dir=opendir($pathToThumbs);
$count=1;
while(($fname=readdir($dir))!==false && $count<=7)
{
$path=$pathToThumbs.$fname;
if($fname!='.' && $fname!='..')
{
echo "<hr>";
echo "<img src='$path'>";
if($count==7)
echo "<button onClick='createGallery'>next</button>";
}
$count++;
}
closedir($dir);
}
createGallery("Thumbs/");
?>