I have a table containing multiple rows of test results, each row includes the ID of the test taker. Using the logged-in user information, I've added additional rows to the table to ensure accuracy. However, when printing the result to the console, only one result is displayed.
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) {
// Display results where 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