I have been creating a application using nodejs, express, jade and mysql. The problem is the front end has two select menu which needs to fetch data from two mysql tables. I am able to fetch only one. I am new to this, so please help me.
Output.jade file:-
block sale
select(id="cbosale", name="cbosale", class="custom-select custom-select-sm")
option(value="") Select Sale
each variable in data
option(value=variable.SaleNo) #{variable.SaleNo}
block state
select(name="cbostate", id="cbostate", class="custom-select custom-select-sm")
option(value="") Select State
each state in data
option(value=state.Statename) #{state.Statename}
App.js file:-
app.get('/output', function(req, res){
db.connect(function(err){
db.query("SELECT DISTINCT(SaleNo) FROM tsales", function(err, result, fields){
res.render('output', {title:"Output",data:result});
})
db.query("SELECT DISTINCT(Statename) FROM tstates", function(err, result, fields){
res.render('output', {title:"Output",data:result});
})
})
})
I know i am missing to identify which dropdown to render on which query, but i dont know how. Kindly help me.