Displaying Default Value In Html Form From Mysql Using Node.js
I am having a scenario where I have to display a form and rather than taking input, I have to display some value extracted from database using nodejs. Below is the expected outcome
Solution 1:
sequelize Raw Queries
returns an array as response. You should check if the array is not empty and extract the ticket
for results[0]
See: https://sequelize.org/master/manual/raw-queries.html
Here a small snippet (Handel the "ticket not found" as you see fit)
router.get("/confirm",function(req,res){
db.query("SELECT * FROM details WHERE Ticket=?",[variabled4],function(err, results, fields){
if (err) throw err;
// on "results.length == 0" handle "ticket not found" flowlet ticket = results[0];
res.render('confirm', { title: 'ticket info', ticket: ticket});
});
});
Post a Comment for "Displaying Default Value In Html Form From Mysql Using Node.js"