Fetch data from DB and display in a dynamically generated select box using jquery and php

Fetch data from DB and display in a dynamically generated select box using jquery and php

I have the code that dynamically generates textboxes and select boxes upon a button click. I want to fetch the data from DB and display in the dynamically generated select box.

Fiddle  http://jsfiddle.net/hEByw/12/  shows how the text and selectboxes are generated dynamically.
Please see the fiddle for HTML and complete jquery code.

I have tried the following part of code to fetch the data from DB and Put into dynamically generated select box(Tax Type) but its not working for me.
  1. //To Display the tax types from DB
  2.        $(function(){
  3.          var items="";
  4.           $.getJSON("get_tax_type.php", function(data) {
  5.           alert(data);
  6.           $.each(data, function(index, item) {
  7.           $('#tax_type' + counter + '' + parseInt(index) + parseInt(1)).empty();
  8.           $('#tax_type' + counter + '' + parseInt(index) + parseInt(1)).append("<option value='" + item.TaxID+ "'>" + item.TaxName+ "</option>");
  9.          });
  10.        }, 'json');
  11.     });

PHP file( (get_tax_type.php)

I feel the way I am doing is wrong.Can anybody suggest where am I doing wrong or the proper way of implementing it. I am newbie in jquery. Any help is appreciated.Thanks in advance.
  1. <?php include('includes/db.php'); 
    $q = "select TaxID, TaxName from tax"; 
    $sql = mysql_query($q); 
    $data = array(); 
    while($row = mysql_fetch_array($sql, true))
    { 
    $data[] = $row; 
    }; 
    echo json_encode($data); 
    ?>