Retain Information over successive Page Releaods in PHP
<p>Here is the Aim of my Program.</p>

<ol>
<li>I Want around 5-6 Circles to be shown on the page, of colors red and green. </li>
<li>When, any of the circle is clicked. Its color changes to BLUE.</li>
<li>Then, if i click any other circle on the page its color should also change to BLUE, and the circle previously clicked should also show as BLUE.</li>
<li>So, if i click all circles one by one, in succesive pageloads, all the circles should show up as blue.</li>
<li>And, when a blue circle is clicked, it should show its original color.</li>
<li>This loop should continue for-ever, until the page is closed.</li>
</ol>

<p>This is what i have done till now.</p>

<pre><code>define("SIZE", 5); //the no. of circles

 class redblock
     {
     var $color;


         function set_color($data)
     {
         $this-&gt;color = $data;
     }
     function get_color()
     {
         return $this-&gt;color;
     }
     function image_source()
     {
         $rval2 = $this-&gt;get_color();
         echo $rval2;
     }
     function display_block()
     {
         $rval = $this-&gt;get_color();
         echo "&lt;img src = '",$rval,"' width=120&gt; &lt;/br&gt; " ; 
         }
 }

for ($i=0 ; $i &lt; SIZE ; $i++ ) //INIT color blocks

             { $rb[$i] = new redblock ; }



for ($i=0 ; $i &lt; SIZE ; $i++ ) //color set
{
    if(!isset($_POST[$i.'form']))
    {    
        if ($i % 2 == 0) //even blocks are green
            $rb[$i]-&gt;set_color("green.jpg");
        else                    //odd blocks are red
            $rb[$i]-&gt;set_color("red.jpg"); 
    }
    if ( $_POST[$i.'form'] == "blue.jpg" )
        $rb[$i]-&gt;set_color("blue.jpg");

    if(isset($_POST[$i.'form']))
        $rb[$i]-&gt;set_color("blue.jpg");
} ?&gt;



&lt;?php

// BOTH BLOCKS when clicked repeatedly should turn to white and fro.

for ($i=0 ; $i &lt; SIZE ; $i++ ) //display the blocks
{
    echo "&lt;form method ='post'&gt;";
    echo "&lt;input type = 'image' width='120' src ='",$rb[$i]-&gt;image_source(),"'&gt;";
    echo "&lt;input type='hidden' name='".$i,"form' value='",$rb[$i]-get_color(),"'&gt;";
        echo "&lt;/form&gt;";
    }

?&gt;
</code></pre>

<p>What Happens, in this code.
1. Suppose, i click Circle 1. It turns to blue.
2. Then i click circle 2, it turns blue, but circle 1 becomes green again. I want circle one to retain the blue color.</p>

<p>Please give me the correct code, or guide me in the right direction. Even, a small help will be largely appreciated.</p>

<p>I have no knowledge of Javascript, etc. I only know PHP and HTML/CSS.</p>

<p>Thank you.</p>
