I know that there are other questions just like this but my code just doesnt seems to work. Could you have a look at my code and tell me where i am wrong.
var mysql = require('mysql');
var client = mysql.createClient({
user: 'jed',
password: 'jed8703',
host: 'localhost',
database: 'jedtest'
});
//var query = client.query(
// 'INSERT INTO testtable '+
// 'SET testid = ?, name = ?, value = ?',
// [1, 'test', 'test']
//);
client.query(
'SELECT * FROM testtable',
function selectCb(err, results, fields) {
if (err) {
throw err;
}
console.log(results[0].Name);
for(var i in results)
{
(function(y)
{
setInterval(function() {
console.log(results[y].Name + 'value:' + results[y].Value );
}, 5000 );
})
}
}
);
client.end();
xintervals which in addition will be executed all at the same time.setInterval()in the first place? (Alarm bells go off in my head whenever I seesetInterval()called from inside a loop...)