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?

Re: Counting posts

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.

Re: Counting posts

Thanks for the quick response. I'll try that and see how I get on.

Re: Counting posts

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:

http://talk.guardian.co.uk

At present it looks like this:

http://www.thebath.net/forum

(My apologies to Rickard for the way I've hacked his code around.)

Re: Counting posts

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

Re: Counting posts

OK, thanks. That works.

Is it possible to get the Quick Post to show only on the last page?