title: php function called by onchange of html select
body: <p>I am learning about php functions and I am having trouble with assigning a new value to a key in a session array based on the users change to a select. (I'm a bit of a noob..).</p>
  
  <p>The select input is part of a <code>foreach</code> loop (<code>foreach($_SESSION['results'] as $players){</code>. <code>$players[0]</code> is a player id number.</p>
  
  <p>Here is the select input:</p>
  
  <pre><code>&lt;select name='place" . $players[0] ."' onchange='placechange(". $players[0] .", this)'&gt; 
  &lt;option value='5'&gt;5th&lt;/option&gt;
  &lt;option value='4'&gt;4th&lt;/option&gt;
  &lt;option value='3'&gt;3rd&lt;/option&gt;
  &lt;option value='2'&gt;2nd&lt;/option&gt;
  &lt;option value='1'&gt;1st&lt;/option&gt; 
  &lt;/select&gt;
  </code></pre>
  
  <p>and the function</p>
  
  <pre><code>function placechange($id, $pla){
     for ($x = 0; $x &lt; count($_SESSION['results']); $x++){
        if ($_SESSION['results'][$x][0] == $id){
           $_SESSION['results'][$x]['place'] = $pla;
        }
     }
  }
  </code></pre>
  
  <p>If the 4th player wins the game, and the select box corresponding to that name is changed to '1st', the desired output is:
  <code>$_SESSION['results'][3]['place'] =&gt; 1;</code> but nothing is changing.</p>
  
  <p>I'm not sure, but I think I am mixing up php functions with js functions? Using a change on the users computer to change an array value that is stored on the server....hmmm..... I guess that doesn't really work...</p>
  
  <p>So how can I use onchange (or similar) to change a php session array value?</p>