Posted on Sunday 17th February 2008 at 07:49 PM | |
zackcez Newbie |
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 Post Count: $threadavatar[post_count] <br> Next find: Code <tr> <td id='fields' align='center' rowspan='2'>$posts[poster] <br> Under that add: Code Post Count: $postsavatar[post_count] <br> Please tell me what you think, what could be fixed ect and errors. |