title: Insert PHP code in JQuery
body: <p>Good day every one. I want to insert my php code in my jquery. I want to show my data in database using PHP and I want to put it in a option box. I used var in jquery plus the code of my php but isn't working. Please help me.
  <br>Shows the data: </p>
  
  <pre><code>     &lt;?php
       $res2 = mysql_query("SELECT * FROM expense_maintenance ORDER BY name Asc");
           while ($result2 = mysql_fetch_assoc($res)){
               $name = $result2["name"];
       ?&gt;
  </code></pre>
  
  <p>jquery code(dynamic adding text box)</p>
  
  <p></p>
  
  <pre><code>    var nitem =0; 
      var ntotal = 0;
      var option = &lt;?php echo" &lt;option value='$name'&gt;$name&lt;/option&gt;";} ?&gt;;
  
          function totalItemExpence(){
              ntotal = 0;
                  $('.expense_cost').each(function(){ 
                      if($(this).val() != ""){
                          ntotal += parseFloat($(this).val()); 
                          }
                      }); 
                  //$('#total').val(ntotal); 
              }
          $(document).on('change keyup paste', '.expense_cost', function() { 
              totalItemExpence();
              mytotal();
              }); 
  
          $('.btn').click(function() { 
              nitem++; 
                  $('#wrapper').append('&lt;div id="div' + nitem + '" class="inputwrap"&gt;' +
                      '&lt;select class="expense_name" id="' + nitem '"&gt;"'+ option +'"&lt;/select&gt;' +
                      '&lt;input class="expense_desc" placeholder="Expense Description" id="' + nitem + '" required/&gt;' +
                      '&lt;input class="expense_cost" onkeypress="return isNumber(event)" placeholder="Expense Cost" id="' + nitem + '" required/&gt; ' +
                      '&lt;br&gt;&lt;br&gt;&lt;/div&gt;');  
                  }); 
  
          $('.btn2').click(function() {           
              ntotal = $('#total').val(); 
                  $("#div" + nitem + " .expense_cost").each(function(){               
                      if($(this).val() != ""){
                          ntotal -= parseFloat($(this).val()); 
                          }
                      }); 
  
                      $("#div" + nitem ).remove();
                          nitem--; 
                      $('#total').val(ntotal); }); 
  </code></pre>