SMF Forum Help: Increasing value in column

Discussion in 'PHP' started by MakeThatDollar, Mar 11, 2007.

  1. #1
    I am currently running a SMF forum and I created a new column in my "smf_members" table called "gcposts."

    Each time this is executed in Subs-Post.php:

    // Increase the post counter for the user that created the post.
    if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']))
    {
    // Are you the one that happened to create this post?
    if ($ID_MEMBER == $posterOptions['id'])
    $user_info['posts']++;
    updateMemberData($posterOptions['id'], array('posts' => '+'));
    }

    I want the "gcposts" column to be increased by 1 based on the member who made the post.

    What would I add within the { } tags to do this, and would anything else need to be added anywhere to update the "gcposts" column? For example, would "gcposts" have to be added to the $user_info array? If so, where do I add this at?

    Thanks!
     
    MakeThatDollar, Mar 11, 2007 IP
  2. Nikolas

    Nikolas Well-Known Member

    Messages:
    1,022
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    150
    #2
    Add this :

    db_query("UPDATE LOW_PRIORITY `smf_members` SET `gcposts` = `gcposts` + 1 WHERE `ID_MEMBER` = $ID_MEMBER LIMIT 1", __FILE__,__LINE__);
    PHP:
     
    Nikolas, Mar 12, 2007 IP
  3. MakeThatDollar

    MakeThatDollar Notable Member

    Messages:
    4,451
    Likes Received:
    158
    Best Answers:
    0
    Trophy Points:
    225
    #3
    Does that get added within the if statement or outside of it?

    Also, what code do I need to add if I were to delete a number from that table? (example: whenever posts are removed from the forum a query is executed to remove the post numbers and post data).
     
    MakeThatDollar, Mar 12, 2007 IP
  4. Nikolas

    Nikolas Well-Known Member

    Messages:
    1,022
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    150
    #4
    1) Inside the if statement

    2) instead of `gcposts` + 1 do `gcposts` - 1
     
    Nikolas, Mar 12, 2007 IP
  5. MakeThatDollar

    MakeThatDollar Notable Member

    Messages:
    4,451
    Likes Received:
    158
    Best Answers:
    0
    Trophy Points:
    225
    #5
    Ok thanks. I'll give this a try later today and update here if it works or doesn't. :D
     
    MakeThatDollar, Mar 12, 2007 IP