hello ,
i wanna do something as below but the problem that names and address out of the connection query are empty how can i assign them and the send them to the page?
app.get('/reports', (req, res)=>{
let sql = "SELECT DISTINCT name from users_table ;";
let names;
let query = connection.query(sql,(err,results) => {
if(err) throw err;
names=results
});
let sql2 = "SELECT DISTINCT address from users_table ;";
let addresss ;
let query2 = connection.query(sql2,(err,results) => {
if(err) throw err;
addresss=results
});
res.render('reports',{
title:'Reports ',
names:names,
addresss:addresss,
})
});