Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 394
0 Users 3 Guests Online

User Post Counts

First, run this in your database:
Code
ALTER TABLE `members` ADD `post_count` INT( 11 ) NOT NULL DEFAULT '0';

Next find:
Code

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;


Change to:
Code
case 'addreply':
//Start of post count data by Zackcez
$id = htmlspecialchars($_POST[id]);
$message = htmlspecialchars($_POST[message]);
$get_post_count = mysql_query("SELECT * FROM `members` WHERE `id` = '$logged[id]'");
$post_count = mysql_fetch_array($get_post_count);
$end_posts = $post_count[post_count]+1;
//End of post count data by Zackcez
$do = mysql_query("UPDATE `members` SET `post_count` = '$end_posts' WHERE `id` = '$logged[id]'");
$insert = mysql_query("INSERT INTO `forum_posts` (`message`, `poster`, `thr_id`) VALUES ('$message', '$logged[username]', '$id')");
$insert = mysql_query("INSERT INTO `members` (`post_count`) VALUES ('$end_posts')");
echo ("Thanks for your reply. <br><a href='javascript: history.go(-1)'>Go back.</a>");
break;

Now you have it so every reply their post count goes up one but you also want it so when you make a new thread that it goes up too, so here that is:

Find:
Code

case: 'addthread':

Replace it all with:
Code

case 'addthread':
//Start of Post Count Data by Zackcez
$get_post_count = mysql_query("SELECT * FROM `members` WHERE `id` = '$logged[id]'");
$post_count = mysql_fetch_array($get_post_count);
$end_posts = $post_count[post_count]+1;
//End of Post Count Data by Zackcez
$id = htmlspecialchars($_POST[id]);
$query = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
$array = mysql_fetch_array($query);
if ($array[locked] == Yes)
{
echo ("You can't post that in here.");
}
else
{
$title = htmlspecialchars($_POST[title]);
$message = htmlspecialchars($_POST[message]);
$insert = mysql_query("INSERT INTO `forum_thread` (`title`, `message`, `poster`, `topic_id`) VALUES ('$title', '$message', '$logged[username]', '$id')");
$do = mysql_query("UPDATE `members` SET `post_count` = '$end_posts' WHERE `id` = '$logged[id]'");
$insert = mysql_query("INSERT INTO `members` (`post_count`) VALUES ('$end_posts')");
echo ("Your thread has been added.<br><a href='javascript: history.go(-2)'>Go back.</a>");
}
break;


Now just to display the data
Find:
Code

<tr>
<td id='mains' align='center' width='120' rowspan='2'><a href=javascript:void(window.open('members.php?user=$thread[poster]','client','status=1,width=400,height=250,top=60,left=60'))>$thread[poster]</a><br>
$threadavatar[title]
<br>

Under that add:
Code

$threadavatar[post_count]
<br>

Next find:
Code
<tr>
<td id='fields' align='center' rowspan='2'>$posts[poster]
<br>

Under that add:
Code

$postsavatar[post_count]
<br>


You're done now, please comment/post errors :o
zackcez
Author:
Views:
2391
Rating:
Posted on Thursday 26th June 2008 at 08:24 PM
dtnet
dtnet
It works fine for me :P
Posted on Friday 22nd February 2008 at 10:32 PM
zackcez
zackcez
It was tested...it's working fine for me...
Posted on Thursday 21st February 2008 at 06:01 PM
new2old
new2old
You have first made it so that it adds one post to the user, and updates the user which is good.

But then you use the INSERT INTO query which will make every member have the $end_post 's

please test the tuts before you post