PHP form processing script
<p>I am trying to write a PHP script for a web page that will dynamically search a directory (hard coded into the script) and each directory it finds in this directory, create a heading and then search that directory and using the first jpg it finds, create a clickable image under the heading. The user clicking the image would send them to a page with all the images in that directory. Basically a dynamic photo gallery.
The script creates form elements from the images. I started using input type=image but found it only returns the x &amp; y coordinates of the click. I need to retrieve some type of value to identify which one got clicked. Then I began using input type=submit using the image as the background. This works except I'd like to be able to scale the image down to a smaller size. Using width and hieght, I can create a smaller submit button but it crops the image. I've also tried input type=button and html button element but my understanding is cross browser compatibility issues make the button element not reliable.
I'd rather not have to create a thumbnail version of the images, I'd rather the script create the whole thing on the fly from what ever images are in each directory.</p>

<p><strong>edit:</strong>
OK, to be more concise as kingkero suggests, I need an image that can be scaled that the user can click which will submit the form and I can collect the value to determine which image got clicked</p>

<pre><code>&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=utf-8"&gt;
&lt;link rel="stylesheet" type="text/css" href="gallery.css"&gt;
&lt;title&gt;title&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action="&lt;?php $_PHP_SELF ?&gt;" method="POST"&gt;
&lt;h3&gt;Picture Gallery&lt;/h3&gt;
&lt;/br&gt;
&lt;?php
$DirPath =dirname(__FILE__).DIRECTORY_SEPARATOR."webpics";
$validPath = "http://somewebsite.com/webpics/";
if(isset($_POST)){
echo "do stuff here";
} else {
    if ($handle = opendir($DirPath)) {
        while (false !== ($entry = readdir($handle))) {
            if ($entry != "." &amp;&amp; $entry != ".." &amp;&amp; is_dir($DirPath.DIRECTORY_SEPARATOR.$entry)){
                echo "&lt;h3&gt;";
                echo $entry;
                echo "&lt;/h3&gt;";
                if ($handle2 = opendir($DirPath.DIRECTORY_SEPARATOR.$entry)) {
                    while (false !== ($entry2 = readdir($handle2))) {
                        if ($entry2 != "." &amp;&amp; $entry2 != ".."){
                            $imgInfo = getimagesize($DirPath."/".$entry."/".$entry2);
                            $width = $imgInfo [0];
                            $height = $imgInfo [1];
                            $new_width = 400;
                            $new_height = floor( $height * ( 400 / $width ) );
                            echo "&lt;input type=\"submit\" id=\"someimage\" value=\" \" style=\"background-image: url(".$validPath.$entry."/".$entry2."); border: solid 0px #000000; width: ".$new_width."px; height: ".$new_height."px; name=\"".$entry2."\"&gt;&lt;br&gt;";
                            break;
                        }
                    }
                }
            }
        }
    }
}
?&gt;
&lt;/form&gt;
&lt;/body&gt;
</code></pre>
