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;
926 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
577 Who developed the "avformat-59.dll" that comes with FFmpeg?
575 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
620 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.