Thread Post Count
First of all the SQL
Code
ALTER TABLE `forum_thread` ADD `posts` VARCHAR( 225 ) NOT NULL default '0',
Next we need the code to add the post to the forum so in forum.php find this bit of code
PHP Code
<?PHP
case 'addreply':
$id = htmlspecialchars($_POST[id]);
$message = htmlspecialchars($_POST[message]);
$insert = mysql_query("INSERT INTO `forum_posts` (`message`, `poster`, `thr_id`) VALUES ('$message', '$logged[username]', '$id')");
echo ("Thanks for your reply. <br><a href='javascript: history.go(-1)'>Go back.</a>");
break;
?>
And then change it to
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?PHP
case 'addreply':
$id = htmlspecialchars($_POST[id]);
$message = htmlspecialchars($_POST[message]);
$fetch_posts = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
$posts = mysql_fetch_array($fetch_posts)//Gets the posts from the select thread
$posts2 = $posts[posts]+1;//Adds 1 post to the forum post cound
$insert = mysql_query("INSERT INTO `forum_posts` (`message`, `poster`, `thr_id`, `posts`) VALUES ('$message', '$logged[username]', '$id', '$posts2')");
echo ("Thanks for your reply. <br><a href='javascript: history.go(-1)'>Go back.</a>");
break;
?>
Next displaying the posts out on the main part :D
Im going to make a new line under the title and have my post count there...But you can change yours to be where ever you like :D
So find:
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?PHP
$threadmessage = "$thread[message]";
$bbctm = BBCODE($threadmessage);
echo ("<tr>
<td id='mains'> </td>");
if($thread[sticky] == Yes)
{
echo ("<td id='mains'><b>Sticky:</b> $bbctt2</td></tr>");
}
else
{
echo ("<td id='mains'><b>$bbctt2</b></td></tr>");
?>
And change it to
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?PHP
$threadpcount = "$thread[posts]"; // Gets the post count
$threadmessage = "$thread[message]";
$bbctm = BBCODE($threadmessage);
echo ("<tr>
<td id='mains'> </td>");
if($thread[sticky] == Yes)
{
echo ("<td id='mains'><b>Sticky:</b> $bbctt2<em>$threadpcount - Posts</em></td></tr>");//Displays post count
}
else
{
echo ("<td id='mains'><b>$bbctt2</b> <em>$threadpcount - Posts</em></td></tr>");
?>
Just a quick tutorials any problems comment below and until then if you have any more requests just PM me or gimmi a shout on the shoutbox when im online..Until then
Bon Voyage!