- in a loop -
- get some data from mysql
- insert the data into specific array ( at the index of i)
 
but as you know, 'i' increases much earlier than I expected. I know it's a problem with a sync/async proplem of nodejs. I wanna change it into synchronous function, but it's too confusing maybe because it's my first time...
...
dbconn.pool.getConnection(function (err, conn) {
...
    for (var i = 0; i < search_result.length; i++) {
        console.log("1, i here : "+i)
        conn.query(sql_getId_and_count, [search_result[i].address], function (err, result) {
              console.log("2.i here:" + i)
              if (err) console.error(err)
              else {
                   console.log("here : " + result[0].counter)
              }
        })
    }
})
 
     
     
    