0

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 MemberID='$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!

Edited by StartingGrounds: n/a

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by StartingGrounds
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.