title: How should I build a control array using html, jQuery
body: <p>I've little more than basic knowledge of the html-php-jquery-ajax combination but I'm a long time at VB. I can best describe what I'm attempting to do in VB terms but I need to do it with in a html/php page that already uses jQuery, ajax and interfaces with php.</p>
  
  <p>I'm querying a db and returning id &amp; description. I want to dynamically build a control array that will represent the returned data.</p>
  
  <p>This function calls the db read from a button onclick event...</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      function loadio(){
          var request = $.ajax({
              url: "/db/loadio.php", type: "POST", datatype: "html"
          }); //request   
          request.done(function(result) { 
              $('#status').html("Result: " + result );
          });  //request.done
          request.fail(function(jqXHR, textStatus) {
              $('#status').html("Request failed: " + textStatus + " " + jqXHR.status );
              }); //request.fail
      }; //loadio
  &lt;/script&gt;
  </code></pre>
  
  <p>It calls to and returns data from this php file...</p>
  
  <pre><code>&lt;?php
      $con = new mysqli('localhost', 'user', 'password', 'dbtable');
          $stmt = $con-&gt;prepare('select id, description from iotable where iotype = 1');  
          $stmt-&gt;execute();
          $stmt-&gt;bind_result($id, $description);
          while ($stmt-&gt;fetch()){
              echo $id, $description, "&lt;br/&gt;";
          }
          $stmt-&gt;close();
      $con-&gt;close();
  ?&gt;
  </code></pre>
  
  <p>So what I want to do is the following:
  Build an array of labels that represents the returned $description, and
  Build a corresponding array of buttons, somehow assigning the #id, so that when clicked they can use the #id as a variable that can be passed to a common function 
  (e.g. alert("Button " + #id + " was clicked");).</p>
  
  <p>If I had to do this in .NET I'd create a class with the controls and events within it and simply create new instances of the class as required, storing all the required variables within that instance.</p>
  
  <p>So here's my question:
  How should I be going about this using html, php, jQuery, ajax?
  Can I create dynamic control arrays?
  Do I need to be considering a completely different approach?</p>
  
  <p>Thanks in advance.</p>