hey i am total new in node.js..
Can U any one please Explain me step by Step how i can display values into dropdownlist.. i have just create a single file.. File name is fetch.js which get(fetch) all the values from mysql.. in the form of JSON.. here is my code..
var http = require('http');
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
port : 3306, //port mysql
user : 'root',
password: '',
database: 'node_js'
});
console.log('MySQL Connection details '+connection);
http.createServer(function (request, response)
{
console.log('Creating the http server');
connection.query('SELECT * FROM `emp` where Branch="PHP"', function(err, rows, fields)
{
console.log('Connection result error '+err);
console.log('no of records is '+rows.length);
response.writeHead(200, { 'Content-Type': 'application/json'});
response.end(JSON.stringify(rows));
response.end();
});
}).listen(8084);
my database
CREATE TABLE IF NOT EXISTS `emp` (
`ID` int(5) NOT NULL AUTO_INCREMENT,
`Name` varchar(25) NOT NULL,
`Address` varchar(25) NOT NULL,
`Branch` varchar(25) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
please help me in this Thanks in Adv.