Javascript for loop doesn't seem to be changing the value of 'i'?

I'm trying to run this loop in which I would like the value of 'i' to change.

However, the value seems to be stuck at zero for all 4 iterations of the loop.

for(var i=0;i<5;i++){

        client.query('SELECT curattend FROM table1 WHERE ind=("++i++")', function(err,result){
        att = result[0].curattend;
        console.log(att)
        });
}

Does anyone have any advice on why this is happening? Thanks!

You didn't include the variable i in your query, you just queried for the hardcoded string ("++i++").

This:

client.query('SELECT curattend FROM table1 WHERE ind=("++i++")', function(err,result){

should be:

client.query('SELECT curattend FROM table1 WHERE ind = ?', [i], function(err,result){

You've put "++i++" inside a string enclosed with single qoutes ('). You must use single quotes to escape the string as well.

Use this:

client.query('SELECT curattend FROM table1 WHERE ind=('+i+')', function(err,result){