Jump to content

I need some help please! =\


Nas[wD]

Recommended Posts

I'm making a code that updates the members' post counts for when a topic (with multiply replys) is deleted

 

theres a 'members' database table with the field 'posts' which i'm trying to update here

and theres a 'forum_replys' table that lists the replys per topic

 

(this is a forum i'm trying to code)

 

$query = "SELECT * FROM forum_replys WHERE forum_reply_location = '$topic'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
extract($row);

$current_post_count = getmemberinfo("posts", $row[author]);

$new_post_count = $current_post_count - 1;

$query = "UPDATE members SET posts = '$new_post_count' WHERE username = '$row[author]";
$result = mysql_query($query) or die(mysql_error());

@mysql_query("DELETE FROM forum_replys WHERE forum_reply_id = \"$row[forum_reply_id]\"");

}

 

This code works in deleting all the replys of the topic, but it doesn't update each member's post counts correctly. it just takes away 1 post per member when some have 2+ replys per topic :(

 

i really can't think of any other PHP code to get the member post counts to update, please help me! i'll be refreshing the forum all day hoping for some help

Link to comment
https://forums.phpfreaks.com/topic/193957-i-need-some-help-please/
Share on other sites

Archived

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

×
×
  • 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.