I have this code that shows all the images inside ‘images’ directory but it is very annoying because all the images are showing on a single page :/
how could i split those images on multiple pages ?
here is the code
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
</head>
<?php
$files = glob("images/*.*");
echo '<div id="design">';
for ($i=0; $i<count($files); $i++) {
$num = $files[$i];
if ($i%3==0){echo '<div class="Row">';}
echo '<img class="img" width="250px" height="250px" src="'.$num.'" alt="random image" />';
if ($i%3==0){echo '</div>';}
}
echo '</div>';
?>
First, try replacnig this line with something more rubust. This will return all files (image or anything else) unless you are sure that only image files are in the folder:
The
$fileswill result in an array with paths to the images, you can easily use this feature to display only the number of images you want in a page.like this:
You can follow the same rules and make a pervious link as well!
Please note, stopping (disabling) NEXT or Pervious links is up to yourself!