SO I have a table with multiple rows of test results. The ID of the test taker is inserted into each row and I have actually inserted more rows into the table using the logged in user so I know its correct. The result is only printing one result to the console
router.get('/tableResults',function(req, res, next) {
console.log(req.session.passport.user);
const db = require('./db_connection.js');
var id = req.session.passport.user;
db.query('SELECT * FROM testResults where id = ?',[id], function(error, results, fields) {
// results are displayed where the user ids match
if(error) throw error;
var results = results[0];
console.log (" 1st " + results);
var tableData = [ results];
console.log (tableData);
res.redirect('/home');
});
});
// error result in putty
Nodemon] starting `node ./bin/www`
24
Connected!
1st [object Object]
[ RowDataPacket {
test_id: 1,
username: 'rr',
gradeOne: 1,
gradeTwo: 7,
gradeThree: 0,
id: 24 } ]
GET /tableResults 302 169.552 ms - 54
24
true
GET /home 304 89.895 ms - -
GET /dist/css/bootstrap.min.css 404 10.086 ms - 3199