How to access a javascript variable with php and store it to the database
<p>I'm currently looking for a way on how I can access a javascript variable and using a php code to store it in the database without using Ajax. The code below is a stripped-down version of what I'm currently working on:</p>

<pre><code>&lt;script&gt;
 function secondPassed() {
   document.getElementById('time').value = parseInt(document.getElementById('time').value) + 1;
   int val = 0;
   num = "&lt;?php $insert = mysql_query('INSERT INTO tbl_timer VALUES(\'\', \"."$val".\"  )',$connection); ?&gt;";}
&lt;/script&gt;
</code></pre>

<p>I'am trying to get the value of val and store it in the database but it will not be inserted. Please tell me where I went wrong with this code.  </p>