Page 1 of 1

Have 'Replies' column start at 1 instead of 0

Posted: Thu Oct 08, 2009 2:32 pm
by Keno2113
I know this may be an odd request but, believe me, I do have a reason for asking. When viewing a forum you have the following columns: Topics - Poster - Replies - Views - Last Post. When a new topic is created the 'Replies' column count (correctly) reflects '0' until a reply is made to the topic and then increments to '1, 2, 3, etc...'.
I need (for a special purpose) the 'Replies' column to start its count at '1' when the topic is created and increment from there on each reply to the topic.

How can I accomplish this?

Thanks in advance.

Re: Have 'Replies' column start at 1 instead of 0

Posted: Thu Oct 08, 2009 3:01 pm
by stevemaury
This SQL will start the post count at 1 for every newly created forum.

Code: Select all

 ALTER TABLE `phpbb_forums` CHANGE `forum_posts` `forum_posts` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '1' ;
For existing forums, run this before running the above:

Code: Select all

UPDATE phpbb_forums SET `forum_posts` = `forum_posts` + 1 WHERE `forum_id` > 0; 
That will add 1 to ALL forum's post counts. If you just want it for certain existing forums:

Code: Select all

UPDATE phpbb_forums SET `forum_posts` = `forum_posts` + 1 WHERE `forum_id` = N; 
Change N to the forum_id and repeat as necessary.

Re: Have 'Replies' column start at 1 instead of 0

Posted: Thu Oct 08, 2009 5:54 pm
by Keno2113
Steve,
Thanks for your reply. I have made the change you suggested and it is now working.