title: how to use a string variable from a php file to a javascript in html
body: <p>my final goal is to convert data from database to a array, then i can print a pretty nice graph with a jquery plugin "flot"
  in html file:</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript" src="jquery.flot.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" &gt;
  $(function test() {   
  var d3= [[0, 3], [4, 8], [8, 5], [9, 13]];   
  $.plot($("#placeholder"), [d3]);
  });
  &lt;/script&gt; 
  </code></pre>
  
  <p>in php file</p>
  
  <pre><code>echo"&lt;script language='javascript' &gt;\n";  
  $k = 0;  
      $agevi = mysql_result($result, $k, "Age"); 
      $snvi = mysql_result($result, $k, "StuNo"); 
  settype($agevi, "integer"); 
  settype($snvi, "integer"); 
  $smallarray = array($snvi,$agevi);  
      $bigarray = array($smallarray);
      $i++;   
  while ($i &lt; $number) 
      { 
        $agev = mysql_result($result, $i, "Age"); 
    $snv = mysql_result($result, $i, "StuNo");  
    settype($agev, "integer"); 
    settype($snv, "integer");  
    $smallarray = array($snv,$agev);   
    array_replace($smallarray,$smallarray);
    array_push($bigarray,$smallarray); 
    echo"\n"; 
    $i++;    
    }  
    echo 'var stunoarr = '.json_encode($bigarray).';'; 
    }    
        echo"\n&lt;/script&gt;";  
    echo  json_encode($bigarray) ; 
        echo "\ndocument.write(\"bigarray array is: &lt;b&gt;" . json_encode($bigarray) .  "&lt;/b&gt;\")";    
        mysql_free_result($result); 
        mysql_close();  
  </code></pre>
  
  <p>what i have in php output is work:</p>
  
  <p>[[1,12],[2,5],[3,6],[4,2],[5,7],[6,2],[7,12],[8,3],[9,6],[10,8],[11,4]] document.write("bigarray array is: [[1,12],[2,5],[3,6],[4,2],[5,7],[6,2],[7,12],[8,3],[9,6],[10,8],[11,4]]") </p>
  
  <p>so people suggesting use json, yes i did, and i also put </p>
  
  <pre><code>&lt;script&gt;
  var myvar = &lt;?= json_encode($bigarray); ?&gt;; 
  &lt;/script&gt;
  </code></pre>
  
  <p>at the end of php file outside ?></p>
  
  <p>how exactly should get the variable from php to javascript in order to produce the graph then..? tried hundrd of ways now still not working...thanks in advance! :D</p>