title: pass a php variable in an anchor tag inside a php loop
body: <p>I have a list of records on a table which look like this..</p>
  
  <p>PHP/HTML CODE:</p>
  
  <pre><code>&lt;script src="js/jquery-3.2.1.js"&gt;&lt;/script&gt;
  &lt;?php
  while($resrecord=mysqli_fetch_array($resdata))
  {  ?&gt;      
    &lt;tr&gt;
          &lt;td&gt; &lt;?php echo $resrecord[0];?&gt;  &lt;/td&gt;
          &lt;td&gt; &lt;?php echo $resrecord[2];?&gt;  &lt;/td&gt;
          &lt;td&gt; &lt;?php echo $resrecord[3];?&gt;   &lt;/td&gt;
          &lt;td&gt; &lt;a onclick="window.open('test.php?id='+'&lt;?php echo $resrecord[0]; ?&gt;','popup','width=600,height=600');"&gt;Tesing&lt;/a&gt;  &lt;/td&gt;
            //also checked with href of anchor tag
    &lt;/tr&gt;
   &lt;?php }   ?&gt;
  </code></pre>
  
  <p>Which means I can't access a php variable in javascript. I also tried these methods</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    var x= '&lt;?php echo $resrecord[0]; ?&gt;';  
    //OR
    var x= '&lt;?php echo json_encode($resrecord[0]); ?&gt;';
      //here x won't populate with above php variables
  &lt;/script&gt;
  </code></pre>
  
  <p>I've also tested the above javascript methods on a simple PHP variable which didn't belong to any loop and still didn't work.</p>