Skip to content Skip to sidebar Skip to footer

Loop To Every Each Row Of Php Array

Hello I have 2 sets of code here and here it is Ajax /* Loop and Get Data from database to create a table */ $(document).ready(function () { $('#btngenerate').click(function(e)

Solution 1:

Try this

$(document).ready(function () { 
   $('#btngenerate').click(function(e){
       var d1 = $('#startdate').val();
       var d2 = $('#enddate').val();
         $.ajax({
            url: 'queries/qryTITO.php',
            type: "POST",
            datatype: 'json',
            data: ({startdate: d1,enddate: d2}),
            success: function(data){
                    $.each(data,function(){
                        $('tr').append("<td>"+this+"</td>")
                    });
            }
        });  
   });
});

here is a Sample Fiddle..

Solution 2:

You could try

$(document).ready(function () { 
  $('#btngenerate').click(function(e){
    var d1 = $('#startdate').val();
    var d2 = $('#enddate').val();
    $.ajax({
      url: 'queries/qryTITO.php',
      type: "POST",
      datatype: 'json',
      data: ({startdate: d1,enddate: d2}),
      success: function(data){
        $(data).each(function(i,res){
          $('table').append("<tr><td>"+res.vdate+"</td></tr>");
        });
      }
    });  
  });
});

Post a Comment for "Loop To Every Each Row Of Php Array"