Determining the current JPG on a page
<p>I'm trying to make a comic viewer that puts all of the images in a directory into an array (they are named <code>1.jpg</code> to <code>26.jpg</code>, etc.), and then you can choose to navigate through them. Making the "first" and "last" links are easy, I just can't seem to figure out how to make the "next" and "previous" links, because I think I need to tell it to determine what image is on the page, and then reference that to know which file to go to next. Here's what I have so far:</p>

<pre><code>    &lt;?php 

    $dir='comics';
    $dir_handle = opendir($dir);
    while (false !== ($file = readdir($dir_handle))) {
    $images[] = $file;
    }  

    $lastcomic = end(array_values($images));

    ?&gt;

    &lt;?php

    echo ("&lt;a href='comics/$lastcomic' target=frame&gt;Last&lt;/a&gt;"); 

    ?&gt;

    &lt;iframe src="null.html" name=frame&gt;&lt;/iframe&gt;
</code></pre>
