I want to increment a value from outside a php block
<p>Basically its a web page where someone would press a button to increment the $selection variable. Globals and statics do not seem to work.
Code looks like this:</p>

<pre><code>&lt;?php

    if(isset($_POST['next'])) 
    {
        displaynext();
    }
    else
    {

        global $image_folder = "/images/";

        echo "global declared";

        global $selection;
        $selection = 1;
    } 

    function displaynext()
    { 
        $selection++;

        if (file_exists($image_folder."/".$selection.".png")) {

        echo "&lt;img src=\"$image_folder/".$selection.".png\"&gt;";

    }
    else {

      echo "No next image was found for $selection in ".$image_folder."/".$selection.".png";

    }

    ?&gt;


    &lt;form action="&lt;?=$_SERVER['PHP_SELF'];?&gt;" method="post"&gt;
    &lt;input type="submit" name="next" value="Next"&gt;
    &lt;/form&gt;
</code></pre>
