Topic: Counting posts
I'd like to add post numbers to the message window on my forum, e.g. '#34 of 56'. Are there variables I can use?
You are not logged in. Please login or register.
PunBB Forums → PunBB 1.2 discussion → Counting posts
I'd like to add post numbers to the message window on my forum, e.g. '#34 of 56'. Are there variables I can use?
I'd just make my own variables, open your viewtopic.php, find
while ($cur_post = $db->fetch_assoc($result))
{
// If the poster is a registered user.
and replace with
$total = $db->num_rows($result);
$i = 0;
while ($cur_post = $db->fetch_assoc($result))
{
$i++;
echo "post $i of $total";
// If the poster is a registered user.
That gives you this
You can then move the echo to wherever you want the info to display.
Thanks for the quick response. I'll try that and see how I get on.
I've added it but it's only counting for each page, then it starts again on the next page.
What I want is my forum to be like this one:
At present it looks like this:
(My apologies to Rickard for the way I've hacked his code around.)
Use this block instead then:
$postcount = $db->query('SELECT max(id) FROM '.$db->prefix.'posts') or error('Unable to fetch post count', __FILE__, __LINE__, $db->error());
$total = $db->result($postcount, 0);
while ($cur_post = $db->fetch_assoc($result))
{
echo "post {$cur_post['id']} of $total";
// If the poster is a registered user.
it will have gaps if you delete posts though
OK, thanks. That works.
Is it possible to get the Quick Post to show only on the last page?
PunBB Forums → PunBB 1.2 discussion → Counting posts
Powered by PunBB, supported by Informer Technologies, Inc.