Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/138992-new-post-count-display/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.