Dropdown populated with database data that adds on button click

     

I am confused how to populate my dropdown that adds on button click with database values . I used jQuery to do the adding function of dropdown on button click. but it seems like i cant populate the options of the select tag inside my jQuery with database values. Please help me out...


This is my php page


prepare('select CompanyName From Company');   $smt->execute();   $data = $smt->fetchAll();   ?>
     
     



  
     
  
  

The jQuery code used to add dropdown on button click is:


EDIT:     


$(document).ready(function(){
var counter = 2;
$("#addButton").click(function () {
if(counter>5){   alert("Only 5 Layers allowed");   return false;   }   var companies = [];   var newTextBoxDiv = $(document.createElement('div'))   .attr("id