I tried making a function to read the comments table, match the logged user's username from the table and then count all of the comments they have made but I just can't get it. For some reason I can't pull the user's actual username into my code.
The point I'm at now is:
- Code: Select all
function totalcomments() {
global $sql;
echo "Total: ".count($sql->select(array('table' => 'comments', 'where' => array("author =".Username Here))));
}
Where you see Username Here is where I need the username that is logged in to appear. I know the code works because if I manually put the user's name into the code but obviously that isn't a practical solution (or one at all). I just can't get the actual username to appear in there on its own once the person is logged in.
Can anyone fit the last puzzle piece into this one?
As always, thanks in advance for preventing me from pulling all of my hair out
