How to print direct links to page numbers, next to the thread subject in a forum?
<p>Ciao,</p>

<p>In my forums where I list all the threads, I want also to show links to pages.</p>

<p>Like:  <a href="http://www.phpbb.com/community/viewforum.php?f=6" rel="nofollow">http://www.phpbb.com/community/viewforum.php?f=6</a> (As you can see, it prints the number of pages for the threads that have more than 1 page.)</p>

<p>How should I do so it prints Page 2 if it has more than 10 posts?</p>

<p>I'm not taking about paging, I have that already. I need to print links for pages for all threads.</p>

<p>I store the number of replies a thread has in its table, so its easy to get that but how should I do this? I have paging for posts in the threads, I print 10 posts per page. I guess could make something like</p>

<pre><code>If num_replies &gt; 10 print &lt;link to threads page 1&gt;
If num_replies &gt; 20 print &lt;link to threads page 2&gt;
If num_replies &gt; 30 print &lt;link to threads page 3&gt;
If num_replies &gt; 40 print &lt;link to threads page 4&gt;
</code></pre>

<p>But that's ridiculous there has to be a better way. </p>

<p>My SQL:</p>

<pre><code>SELECT t.id,t.poster,t.soggetto, t.posted,t.recentissimo,t.ultimo_id,t.num_views, t.num_replies, t.closed,t.sticky,t.moved_to
FROM threads AS t
WHERE t.forum_id=$id
ORDER BY t.sticky DESC, t.last_post DESC
LIMIT $startIndex, $threadsPerPage
</code></pre>

<p>Thanks!</p>
