here is my code.
var http=require("http");
var fs = require("fs");
var express = require("express");
var app = express();
var path = require("path");
var mysql = require('mysql');
var ejs = require("ejs")
var bodyParser = require('body-parser');
app.set('view engine' , 'ejs');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "testn"
});
con.connect(function(err) {
if (err) throw err;
con.query("SELECT * FROM form", function (err, result, fields) {
if (err) throw err;
console.log(JSON.stringify(result));
app.get('/', function(req, res) {
res.render('index',{data:JSON.stringify(result)});
});
});
});
app.listen(3010);
console.log("Running at Port 3010");
Run code snippetExpand snippet
and here is my html
<!DOCTYPE html>
Document
Run code snippetExpand snippet
and here is my output
[{"name":"Prakash","email":"
[email protected]","description":"uykiukjk"},{"name":"Mathan","email":"
[email protected]","description":"uykiukjk"},{"name":"prakashvpsm","email":"
[email protected]","description":"uykiukjk"},{"name":"Prakash","email":"
[email protected]","description":"wddfwdpfk"},{"name":"Prakash","email":"
[email protected]","description":"uykiukjk"}]
but i dont want in json format .i want without only the data. The data is fetched from local server
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)