так не работает
ничего не выдает т.е. не входи в цикл j
app.get('/orders/:page', (req, res) => {
var connection = getMySQLConnection();
var smartphone=[];
var allsmartphone=[];
var smartphoneList=[];
var allprice=0;
var a;
var b;
var length;
var orderids;
var start;
var end;
var allprice;
start=(req.params.page-1)*10;
end=req.params.page*10;
var sql2='SELECT `orderid` FROM `orders` GROUP BY `orderid`';
var sql1 ='SELECT `id`,`prod`,`name`,`photo`,`price`,`sale`,`remote_adr`,`quantity` FROM `orders` WHERE orderid=?';
connection.connect(function(err) {
if(err){
console.log(err);
}else{
connection.query(sql2, [], function (err, resulta) {
length=resulta.length;
if(start<0){start=0;}
if(end>(length-req.params.page*10)%10){end=length;}
orderids=resulta;
for(var j=0;j<orderids.length;j++) {
smartphone=[];
connection.query(sql1, [orderids[j]], function (err, results) {
if(err){
console.log(err);
}else{
for (var i = 0; i < results.length; i++) {
// Create the object to save the data.
b = results[i].price - results[i].price * results[i].sale / 100;
a = b * results[i].quantity;
allprice += a;
var smart = {
'id': results[i].id,
'prod': results[i].prod,
'name': results[i].name,
'photo': results[i].photo,
'sale': results[i].sale,
'price': results[i].price,
'tsale': b,
'vsego': a,
'quantity': results[i].quantity,
'allprice': allprice,
};
smartphone.push(smart);
console.log(smartphone);
console.log(orderids);
}
}
});
//allsmartphone[orderids[j]].push(smartphone);
};
//res.render('orders', {"smartphoneList": smartphoneList,"allsmartphone": allsmartphone,'orderids':orderids});
});
};
});
});