|
Help with some coding
What I want to do, is get the exact number of posts which should be on a page if it's the last page of a thread. I have the page length, I have the number of pages and I have the total number of posts in a thread. Now what I'm doing is this following bit of code:
(page * PageLength <= ThreadPostCount ? PageLength : ThreadPostCount - (page - 1) * PageLength);
Pretty much, if the total number of posts to the end of this page(page * page length) are less than or equal the length of the thread, I use the given pagelength. If not I subtract the number of posts on pages preceding this page and subtracting it from the total length, to get the exact number to display.
I'm sure that there is an easier approach I just can't think of it.
|