title: Using HTML table tags inside script
body: <p>Using this example <a href="https://www.jqueryscript.net/table/jQuery-Plugin-To-Generate-A-Table-From-A-CSV-File-CSV-Parser.html" rel="nofollow noreferrer">https://www.jqueryscript.net/table/jQuery-Plugin-To-Generate-A-Table-From-A-CSV-File-CSV-Parser.html</a> </p>
  
  <p>I set up a HTML table that takes a CSV file from multiple Raspberry PIs (via SSH) and displays this CSV output as a HTML table:</p>
  
  <pre><code>2018-03-22 12:43:21,NM_Test.h264,-2
  </code></pre>
  
  <p>My HTML page runs the following script:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;body&gt;
  &lt;div id="container"&gt;&lt;/div&gt;
  
  &lt;script&gt;
      $.get('ssh.php', function(data) {
          // start the table
          var html = '&lt;table"&gt;';
          // split into lines
          var rows = data.split("\n");
          // parse lines
          rows.forEach( function getvalues(ourrow) {
              // start a table row
              html += "&lt;tr&gt;";
              // split line into columns
              var columns = ourrow.split(",");
              html += "&lt;td&gt;" + columns[0] + "&lt;/td&gt;";
              html += "&lt;td&gt;" + columns[1] + "&lt;/td&gt;";
              html += "&lt;td&gt;" + columns[2] + "&lt;/td&gt;";
              // close row
              html += "&lt;/tr&gt;";
          })
          // close table
          html += "&lt;/table&gt;";
          // insert into div
          $('#container').append(html);
      });
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My SSH.php:</p>
  
  <pre><code>// set up SSH2 conenctions using config.php to connect to multiple PIs and execute:
  
  echo $ssh-&gt;exec('tail -1 /var/log/playlog.csv');
  </code></pre>
  
  <p>Config.php:</p>
  
  <pre><code>return [
  [
      "name" : "test1",
      "ip" : "127.0.0.1",
      "port": 97,
      "key" : 'ssh-dss AAAAB3NzaC1kc3MAA...c3=',
  ]
  [ ... ]
  ];
  </code></pre>
  
  <p>In my HTML table how can I add column names such as:</p>
  
  <pre><code>&lt;tr&gt;
      &lt;th&gt;PI Name&lt;/th&gt;
      &lt;th&gt;Date/Time&lt;/th&gt;
      &lt;th&gt;Playing&lt;/th&gt;
      &lt;th&gt;Error&lt;/th&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>But for the 'PI Name' column how can I return the corresponding 'name' that I have defined for each PI inside my config.php file?</p>
  
  <p>I'm having difficulty with using HTML tags inside jQuery. </p>