title: Using Php value in jQuery script
body: <p>how would I go about using a php value in jQuery ?, what I am doing is pulling the vat rate from the database using php as follows and storing in $vatrate :</p>
  
  <pre><code>$sqlv = &lt;&lt;&lt;SQL
  SELECT *
  FROM   `vatrate`
  WHERE  id='1'
  SQL;
  if(!$resultv = $db-&gt;query($sqlv)){
    die('There was an error running the query [' . $db-&gt;error . ']');
  }
  while($rowv = $resultv-&gt;fetch_assoc()){
      $vatrate =  $rowv['vatrate'];
  } ?&gt;
  </code></pre>
  
  <p>Then I have my jQuery script that adds all of the line totals together and puts it into a span.</p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function() {
      $('input').on('keyup', function() {
          var rawValue, grandtotal = 0;
          $('span[id^="linetotal"]').each(function(i, elem) {
              rawValue = $.trim($(this).text());
              if (rawValue == '') rawValue = 0;
              grandtotal += parseFloat(rawValue);
          });
          $('#grandtotal').text(grandtotal);
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>But now im not sure how to reference the $vatrate value declared in php in jQuery, so that I can get the price + vat. VAT is sales tax for anyone not in the Uk :)  .</p>