I'm trying to make my own api using a JSON and PHP script, which is successfully working (api.mystem.tk/product), however I want to convert that data to an html table with the columns: id, name and date.

My question, how? I've got my code included and you can watch the JSON output in the console of api.mystem.tk/product. I've deleted all the private details in the scripts and replaced them with #\_\_\_\_\_\_.

**api.php**:

```
<?php
  $connect = mysqli_connect('#host', '#user', '#password', '#db');
  if(!isset($_GET['function'])) {
    die('Some error occurred!');
  }
  function GetProducts($db) {
    $sql = mysqli_query($db, 'SELECT * FROM php_test ORDER BY Id ASC LIMIT 
      0, 10');
    $data = array();
    if (mysqli_num_rows($sql) > 0) {
      while ($row = mysqli_fetch_array($sql)) {
        $data[] = $row["Id"];
        $data[] = $row["Name"];
        $data[] = $row["Date"];
      }
    }
    $data = json_encode($data);
    echo $_GET['jsonCallback'].'('.$data.')';
  }
  if (function_exists($_GET['function'])) {
    $_GET['function']($connect);
  }
  echo $data;
?>

```

**function**.js:

```
$(function(){
  var functionName = 'GetProducts';
  function LoadData() {
    $.getJSON("http://api.mystem.tk/product/api.php? 
    function="+functionName+"&jsonCallback=?", function(data) {
      var all_data = [];
      $.each(data, function(k, name){
        var array_data = '<div class="names">'+name+'</div>';
        all_data.push(array_data);
      });
      $('#data').append(all_data);
      console.log(data);
    });
  }
  LoadData();
});

```

**index**.php:

```
<!DOCTYPE html>
<html lang="en">
  <head>
    <title> API TEST </title>
    <meta name="viewport" content="width=device-width,initial- 
      scale=1,maximum-scale=1,user-scalable=0">
    <script src="https://code.jquery.com/jquery-3.3.1.min.js" 
      integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" 
      crossorigin="anonymous"></script>
  </head>
  <body>
    <div id="data"></div>
    <script type="text/javascript" src="function.js"></script>
  </body>
</html>

```