Question: 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){
       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){
                console.log(data);
            }
        });  
   });
});

```

and here is the `PHP`

```
<?php
    require 'conn.php';
    $startdate = $_POST['startdate'];
    $enddate   = $_POST['enddate'];
    $sql       = "SELECT vdate FROM tablename WHERE date(vdate) between date('" . $startdate . "') and date('" . $enddate . "')";
    $result    = mysqli_query($con,$sql);
    $row       = mysqli_fetch_row($result);
    $jsonData = array();
    while ($array = mysqli_fetch_row($result)) {
        $jsonData[] =  $array;
    }
    echo json_encode($jsonData);
    mysqli_close($con);
?>

```

here is my question. I am trying to return the value back to the jquery so I can create a HTML Table. actually it is working and this is the output

[![enter image description here](https://i.stack.imgur.com/vs8xH.png)](https://i.stack.imgur.com/vs8xH.png)

My question here is how can I make an HTML table for that data?

Here is the error i get

[![enter image description here](https://i.stack.imgur.com/sZ7hq.png)](https://i.stack.imgur.com/sZ7hq.png)

Answer: 
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**](http://jsfiddle.net/mWvjM/36/)..
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>");
        });
      }
    });  
  });
});

```