Stotty Posted December 31, 2008 Share Posted December 31, 2008 Im using this code to add up my Post count (creds Blade ) $sql = mysql_query("SELECT posts FROM km_users WHERE playername = '$player'"); $sql = mysql_fetch_assoc($sql); $posts = $sql['posts']; $sql = mysql_query("UPDATE km_users SET posts = '".($posts + 1)."' WHERE playername = '$player'"); thats on post.php and reply.php its adding perfect ive got 2 users on called "k" and one called "one" one has 5 posts and k has 3 if on messages.php i add this code $sql = mysql_query("SELECT posts FROM km_users WHERE playername = '$player'"); $sql = mysql_fetch_assoc($sql); $posts = $sql['posts']; print "<br>"; print "Posts :"; echo $posts; it displays 3 Posts for every user that would be K's post count how can i make it display each users post count not just 1 users my mysql is like this CREATE TABLE `km_users` ( `ID` bigint(21) NOT NULL auto_increment, `status` int(11) NOT NULL default '0', `playername` varchar(15) NOT NULL default '', `password` varchar(255) NOT NULL default '', `email` varchar(255) NOT NULL default '', `validated` int(11) NOT NULL default '0', `validkey` varchar(255) NOT NULL default '', `tsgone` bigint(20) NOT NULL, `oldtime` bigint(20) NOT NULL default '0', `lasttime` bigint(20) NOT NULL default '0', `posts` int(11) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; Thanks in advanced Quote Link to comment https://forums.phpfreaks.com/topic/138992-new-post-count-display/ Share on other sites More sharing options...
Stotty Posted December 31, 2008 Author Share Posted December 31, 2008 Added mysql info Quote Link to comment https://forums.phpfreaks.com/topic/138992-new-post-count-display/#findComment-726902 Share on other sites More sharing options...
Stotty Posted December 31, 2008 Author Share Posted December 31, 2008 Anyone Please Quote Link to comment https://forums.phpfreaks.com/topic/138992-new-post-count-display/#findComment-726910 Share on other sites More sharing options...
revraz Posted December 31, 2008 Share Posted December 31, 2008 You seriously need to wait a little before you start bumping your thread. Quote Link to comment https://forums.phpfreaks.com/topic/138992-new-post-count-display/#findComment-726916 Share on other sites More sharing options...
premiso Posted December 31, 2008 Share Posted December 31, 2008 Not solving the problem just making this more efficient: $sql = mysql_query("UPDATE km_users SET posts = (`posts`+1) WHERE playername = '$player'"); I believe that is all you would need to add 1 to posts, saves you from having to select each time. As for your real issue, make sure you are not entering the same playername each time and that it is being changed properly. Quote Link to comment https://forums.phpfreaks.com/topic/138992-new-post-count-display/#findComment-726943 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.