I am using the code <?php echo $commentcount++;?> to supply the comment number behind the comment text, though it skips the first comment when numbering and puts a "1" behind comment number "2". How do I fix this?
I am using the code <?php echo $commentcount++;?> to supply the comment number behind the comment text, though it skips the first comment when numbering and puts a "1" behind comment number "2". How do I fix this?
Just add
$commentcount = 1;
above the loop.
The reason is that the "++" is called AFTER the echo.
So in the first comment the $commentcount is not yet defined, therefore nothing is being displayed.
I suggest to use "error_reporting = E_ALL" in your php.ini of your development environment so that you get error notices, which are quite helpful when developing...
Thank you for your help.
This topic has been closed to new replies.