title: Using javascript function and variables in combination with PHP and MYSQL
body: <p>On my page I have a search result that contains a list with users where each is followed by an "<strong>addfriend</strong>" button. Each row contains a <strong>username</strong> and <strong>userID</strong>. Meanwhile the ID of the user that requested the searchresult is stored in a Session variable.</p>
  
  <p>When the addfriend-botton is clicked the following 2 things should happen:</p>
  
  <ol>
  <li>Store the <strong>userID</strong> and <strong>$_SESSION['userID']</strong> is a MySQL table which describes the relationship.</li>
  <li>Do <strong>NOT refresh</strong> the page (this the core of my problem) but stay focussed and change the state of the button to e.g. "friend request send". I'm thinking of GetElementByID().style method.</li>
  </ol>
  
  <p>I was thinking of this:</p>
  
  <pre><code>&lt;a href="#" onClick="addFriend('&lt;? echo $_SESSION['userID'];?&gt;','&lt;? echo $rij['userID']; ?&gt;')"&gt;
  </code></pre>
  
  <p>which calls the <strong>javascript function addfriend</strong></p>
  
  <p>I was hoping to catch the two ID's like this:</p>
  
  <pre><code>&lt;script&gt;
  function addfriend(id1, id2)
  {
      //server side php code where I use value of 
      //the client-side javascript variables: +id1+ and +id2+ .
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Is this at all possible or I'm I thinking the wrong way? Any suggetions on how to accomplish this?</p>