title: Adding database retrieved data inside a for-loop
body: <p>I'm retrieving data from MySQL. All works fine. </p>
  
  <p>My question is how do I add a for-loop correctly inside <code>function(data){ }</code>? Below is what I tried. But <code>data[0].color1</code> , <code>data[0].color2</code> , <code>data[0].color3</code> does not work inside the for-loop. How do I get the for-loop to work?</p>
  
  <pre><code>   var box = ['blk','red','yelw'];
  
      $.post('my.php',
          { stu:"Jamie" },
      function(data){
        for(i = 0; i&lt;box.length; i++){
          $('#'+box[i]).text( data[0].color+i );
        }
      });
  </code></pre>
  
  <p>//this works (without a for loop)</p>
  
  <pre><code>  $('#blk').text(data[0].color1);
    $('#red').text(data[0].color2);
    $('#yelw').text(data[0].color3);
  </code></pre>