Jump to content

Recommended Posts

You can get a count like this, then just pop that value back into the right table.
[code=php:0]$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `posts` WHERE `member_id`='$mid'"),0);[/code]
Or you can just run a query every time the user makes a post.
[code=php:0]mysql_query("UPDATE `members` SET `posts`=`posts`+1 WHERE `id`='$mid'") or die(mysql_error());[/code]
i dont understand^ so i tried this:

[code]
<?php
  ob_start();
  include("config.php");


$count_user_post = mysql_query("SELECT post FROM replies WHERE username = '$logged[username]' ") or die(mysql_error());
$count_user_row = mysql_fetch_array($count_user_post);
$count_add = $count_user_row['post'];
mysql_query("UPDATE users SET posts = '$count_add'+1 WHERE username = '$logged[username]' ");
?>
[/code]

but when i post it only adds 1 and it doesnt increase
SA means that, after the line where you put "INSERT blah blah blah" (this is where after the user hit the submit and make a post), below it you just put another query
[code] $count_user_post = mysql_query("SELECT post FROM replies WHERE username = '$logged[username]' ") or die(mysql_error());
$count_user_row = mysql_fetch_array($count_user_post);
$count_add = $count_user_row['post'];
mysql_query("UPDATE users SET posts = '$count_add'+1 WHERE username = '$logged[username]' ");[/code]

Overall:
After a user made a post, it will auto update their post count.
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.