I have this array:
<?php
$arrFiles = array_diff(scandir("scans", 0), array(".", ".."));
$arrFiles = array_values($arrFiles);
?>
that prints fine with this:
<?php
print_r(array_values($arrFiles));
?>
and these buttons that I want to use to skip from one image to the prev or next:
<a href="javascript:skipLeft()"><img src="/ico/skip_left.gif" width="12" height="12" hspace="1" vspace="1" />skip left</a> /
<a href="javascript:skipRight()"><img src="/ico/skip_right.gif" width="12" height="12" hspace="1" vspace="1" />skip right</a>
I probably need some kind of loop, -1 and +1 or prev and next or something.
I've tried so many things. No luck.
You will probably want a loop like this:
for($i=0; $i < sizeof($arrFiles); $i++)
{
echo "<img src=scans/" . $arrFiles[$i] . ">";
}
to select an image using a page by page technique you could use this:
if($_GET['p'] >= sizeof($arrFiles)) echo "<img src=scans/" . $arrFiles[sizeof($arrFiles)] . ">";
else{
echo "<img src=scans/" . $arrFiles[$_GET['p']] . ">";
}
use this for links/buttons
echo "<a href='yourpagename.php?p=" . $_GET['p']+1 . "'>"; // next
echo "<a href='yourpagename.php?p=" . $_GET['p']-1 . "'>"; // previous
you can use the same if as above to filter out max of array size and obviously use 0 as min array size to cover the low end
if(!max){ //shownext }
if(!min){ //showprevious }
note this is not going to work without proper structuring but you can get the idea