Tuesday 30 May 2017

Access passed mysql data in jade file

I want to access the data on mysql passed from nodeJS in the jade file. I tried the same method in a table it worked. But retrieving data to text boxes is not working.. Im new to NodeJS and jade. Please help

HTML FILE

html
head 

body

each row in rows
var id = row.id;
var name = row.name;
var age = row.age;
var city = row.city;
var department = row.department;

Id :  input(type='text' value= id)
Name  :  input(type='text' value=name)
Age :   input(type='text' value= age) 
City :  input(type='text' value= city)
Department :  input(type='text' value=department)

myapp.js

app.get('/editPage/:id', function(req, res) {
    console.log('GET/');
   // res.sendFile(__dirname + '/viewDetails.jade');

     var pid = req.params.id;   
    connection.query('SELECT * FROM test where id= ?',[pid],function(err,rows){

     if(err){
        console.log('Connection result error '+err);
     }
        console.log('num of records is '+rows.length);
        res.render('editDetailsPage',{rows:rows})



via Tharaka_Ravishan

No comments:

Post a Comment