Jump to content

Forum Indicator Problem


AdamScoville

Recommended Posts

Hello everybody, I'm very excited to find a community towards programming.

 

I've been doing web development for about 5 years now, and I'm starting to get down some serious projects, one of which I need help with right now.

 

Over at: http://www.startinggrounds.com/forums.php

 

Problem:

In forums.php I have this:

if($count >= 1)
		{
			while($post_ind = mysql_fetch_array($check))
			{
				mysql_query("INSERT INTO thread_indicators (ForumID, ThreadID, UserID) VALUES('$forum[ForumID]', '$post_ind[ThreadID]', '$logged[MemberID]')");
			}
			echo $new;
		}
		else
		{
			$count = mysql_num_rows(mysql_query("SELECT ind_id FROM thread_indicators WHERE ForumID=$forum[ForumID] AND UserID=$logged[MemberID]"));
			if($count >= 1)
			{
				echo $new;
			}
			else
			{
				echo $old;
			}
		}

 

This is used to check for new posts.

 

On viewforum.php I have:

 

<?php
	if(!$logged['Username'])
	{
		$history = time()-(60*60*24*7);

		echo ($row['LastPostDate'] >= $history) ? $new : $old;
	}
	else
	{
		$check = mysql_num_rows(mysql_query("SELECT `ind_id` FROM `thread_indicators` WHERE ThreadID='$row[ThreadID]' AND UserID='$logged[MemberID]'"));

		if(!$check && ($row['LastPostDate'] >= $_SESSION['sglastvisit']))
		{
			mysql_query("INSERT INTO thread_indicators(ForumID, ThreadID, UserID) VALUES('$_SESSION[sgforum]', '$row[ThreadID]', '$logged[MemberID]')");
			echo $new;
		}	
		elseif($check)
		{
			echo $new;
		}
		else
		{
			echo $old;
		}
	}
?>

 

Continued to show where the new posts are. And they indicate properly. Here is the problem.

 

When you view the thread it removes the record for the new post stored in "thread_indicators" in the MySQL DB as it should, but when you go back to the forum homepage it's showing the post as new again.

 

Here is my header:

    if($logged['Username']) {
  	
	$time = time();

	$getlast = mysql_fetch_array(mysql_query("SELECT LastVisit FROM members WHERE MemberID='$logged[MemberID]'"));
	$lastvisit = $getlast['LastVisit'];

	$_SESSION['sglastvisit'] = $lastvisit;

	mysql_query("UPDATE members SET Online='$time', LastVisit='$time' WHERE UserID='$logged[MemberID]'");


  }

 

And viewthread.php coding for the deletion:

 

    $timeread = time();

	/***
		Declare Post Read
	*/
	@mysql_query("DELETE FROM `thread_indicators` WHERE ThreadID='$threadid' AND UserID='$logged[MemberID]'");
	@mysql_query("OPTIMIZE TABLE thread_indicators");

 

Can anyone solve this problem or help me with a more appropriate method of doing so?

 

Thank you for your time to read my huge post and help me! :)

Link to comment
https://forums.phpfreaks.com/topic/203823-forum-indicator-problem/
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.