Jump to content

Archived

This topic is now archived and is closed to further replies.

scheols

How Can i log Users Post in my Database?

Recommended Posts

Alright im a lil confused  ??? how can i make my database know that when a user makes a topic or a reply that it counts up as a post and log it in my DB?

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.