title: How to display mysql query result in html table in nodejs?
body: <p>Following is an example of a query result in <code>Nodejs</code>.</p>
  
  <p><strong>Nodejs:</strong></p>
  
  <pre><code> [ RowDataPacket {
             id: 1,
  booktitle: 'Leading',
  bookid: '56353',
  bookauthor: 'Sir Alex Ferguson' },
   RowDataPacket {
  id: 2,
  booktitle: 'How Google Works',
  bookid: '73638',
  bookauthor: 'Eric Smith' },
  RowDataPacket {
  id: 3,
  booktitle: 'The Merchant of Venice',
  bookid: '37364',
  bookauthor: 'William Shakespeare' } ]
  </code></pre>
  
  <p>I need this data to be displayed in the following <code>html</code> format</p>
  
  <pre><code>booktitle               bookid         bookauthor
  -----------------------------------------------------------
  Leading                  56353          Sir Alex Ferguson
  How Google Works         73638          Eric Smith
  The Merchant of Venice   37364          William Shakespeare
  </code></pre>
  
  <p>I tried to get the key and value separately using the following code</p>
  
  <pre><code> for(var i = 0; i &lt; JSONObject.length; i++) {
   for(var val in JSONObject[i]) {
   console.log(JSONObject[i][val])
     }
  }
  </code></pre>
  
  <p>But this doesn't worked as expected. My data will be dynamic. The key and value will be keep on changing. So i can't  access the value with  JSONObject[i].booktitle like that. How can i get a general solution? How can i display the data in table format.</p>