Hello, I'm making a web page with node.js.
DB is using mysql, and I want to increase the view count when I press the post.
/////////////////////////
router.get('/read/:idx',function(req,res,next) // When inquiring, logic processing statement
{
var idx = req.params.idx;
pool.getConnection(function(err,connection)
{
var sql = "select idx, creator_id, title, content, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, hit from board where idx=?";
connection.query(sql,[idx], function(err,row)
{
if(err) console.error(err);
res.render ('read', {title:"text content", row:row[0]});
connection.release();
}); });
It looks like this When rendering it as a read page here, I want to make it count (hit +1) but I don't dare to catch it because it's a beginner.
Please help me!
node.js
You can increase the value stored in the DB whenever there is a read request for the post.
UPDATE board SET hit = hit + 1 WHERE idx = 1;
© 2025 OneMinuteCode. All rights reserved.