title: Displaying JSON from an API in and HTML table using PHP
body: <p>I realize there is likely something very easy I'm missing here.  Also, I'm very new to php so please keep that in mind when responding :)</p>
  
  <p>I am trying to display the results from an API call in an html table.  Here is my code:</p>
  
  <pre><code>// construct the query with our apikey and the query we want to make
  $endpoint = 'http://www.coinmine.pw/api.php?method=coinprofit';
  // setup curl to make a call to the endpoint
  $session = curl_init($endpoint);
  // indicates that we want the response back
  curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
  // exec curl and get the data back
  $data = curl_exec($session);
  // remember to close the curl session once we are finished retrieveing the data
  curl_close($session);
  // decode the json data to make it easier to parse the php
  $search_results = json_decode($data, true);
  if ($search_results === NULL) die('Error parsing json');
  //print_r($search_results);
  
  echo '&lt;table&gt;';
  foreach ($search_results as $coin) {
  
  $name = $coin["name"];
  $profit = $coin["profit"];
  
  echo '&lt;tr&gt;&lt;td&gt;' . $name . '&lt;/tr&gt;&lt;/td&gt;';
  echo '&lt;tr&gt;&lt;td&gt;' . $profit . '&lt;/tr&gt;&lt;/td&gt;';
  
  }
  echo '&lt;/table&gt;';
  </code></pre>
  
  <p>All the above outputs is name profit name profit name profit but with no separate table rows.  </p>
  
  <p>Ideally I'd like the whole api call to be in a table, but I'm just trying to get this to display properly first so I can figure out making the whole table.</p>
  
  <p>Bonus points if someone can point me in the right direction to make the table sortable by each column.</p>