Nas[wD] Posted March 3, 2010 Share Posted March 3, 2010 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 More sharing options...
Nas[wD] Posted March 3, 2010 Author Share Posted March 3, 2010 My friend on aim suggested: do a for* loop within the while loop but I don't know how to do this!!! please help! Link to comment https://forums.phpfreaks.com/topic/193957-i-need-some-help-please/#findComment-1020741 Share on other sites More sharing options...
Jynxis Posted March 3, 2010 Share Posted March 3, 2010 I then corrected myself, and told him to count the amount of each users posts, and then subtract from that number. Link to comment https://forums.phpfreaks.com/topic/193957-i-need-some-help-please/#findComment-1020747 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.