Пытаюсь генерить таблицу,но возникает вот такая лабуда. Кто знает, как это лечить?
var express = require("express");
var bodyParser = require("body-parser");
var app = express();
var mysql = require('mysql');
var http=require('http');
var urlencodedParser = bodyParser.urlencoded({extended: false});
app.use(express.static(__dirname + "/public"));
app.post("/evaluation", urlencodedParser, function (request, response) {
if (!request.body) return response.sendStatus(400);
console.log(request.body);
year = request.body.year;
section = request.body.section;
var con = mysql.createConnection({
host: "localhost",
user: "Professor",
password: "Professor123",
database: "cotc"
});
con.connect(function (err) {
if (err) throw err;
con.query("select theory.Surname,theory.Name from theory,custumers where ((theory.id=custumers.id) and (custumers.Section='" + section + "')) and(custumers.Year='" + year + "')",
function (err, result, fields) {
console.log(result);
console.log(result.length);
response.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'});
/*var i=0;
while (i < result.length) {
response.end( result[i].Name+' '+result[i].Surname);
i++;*/
function tableCreate(x, lenx) {
var body = document.getElementsByTagName("body");
var tbl = document.createElement("table");
for (var j = 0; j <= result.lenx; j++) {
var row = document.createElement("tr");
for (var i = 0; i < 1; i++) {
var cell = document.createElement("td");
var cellText = document.createTextNode(result[j].Name);
cell.appendChild(cellText);
row.appendChild(cell);
}
tblBody.appendChild(row);
}
tbl.appendChild(tblBody);
body.appendChild(tbl);
tbl.setAttribute("border", "2");
}
tableCreate(result, result.length);
});
});
})
app.listen(8081,console.log("8081"));