You can pass the user ID to the page where you want to insert the comment using the url like: insert_comment.php?userID=3
Then insert the userID into the comments table with the comment. Just add a CommentForUser column to your comments table and insert the user ID there.