title: Display mysql in a html table with Node.js
body: <p>i'm learning how to use node.js with mysql. I've tried to find some good documentation but in vain. i'm at the point where I can get my mysql data displayed in my browser but I want to handle it through my index.html and a css file at some point. </p>
  
  <p>This is my app.js: </p>
  
  <pre><code>// moduels
  var express = require('express');
  var app = express();
  var mysql = require('mysql');
  var bodyParser = require('bodyParser')
  
  // 
  app.use(express.static(__dirname + '/public'));
  app.use(bodyParser.urlencoded({extended: false}));
  
  // connect to database
  var con = mysql.createConnection({
      host: "localhost",
      user: "root",
      password: "1234",
      database: "BathBombs_DB"
  });
  
  // routes
  app.get('/', function(request, response){
      console.log('GET request received at /') 
      con.query("SELECT * FROM customers", function (err, result) {
          if (err) throw err;
          else{
              response.send(result)
          }
  
      });
  });
  
  // listen for trafic and display on localhost:9000
  app.listen(9000, function () {
      console.log('Connected to port 9000');
  });
  </code></pre>
  
  <p>My index.html site looks like this:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="ie=edge"&gt;
      &lt;title&gt;Document&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;form action="/" method="POST"&gt;
              &lt;table type="text" name="firstname" &gt;&lt;/table&gt;
      &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>