Here is my php code:


$sql2 = 'SELECT `username`, `user_lastvisit` FROM `phpbb_users` where `user_rank` = 1 or `user_rank` = 2 or `user_rank` = 6 or `user_rank` = 5 AND `user_lastvisit` < (unix_timestamp(now()) - 604800) ORDER BY `user_lastvisit` DESC';

$result2 = mysql_query($sql2,$dbh2);

print "<br><br>In-Active Council Member.<br><br>";

while($result2_row = mysql_fetch_array($result2)){
//  Simple output to screen
	{
		if ($result2_row['username'] != 'user10') 
			{
				$unixtime = $result2_row['user_lastvisit'];
				echo $result2_row['username'], " - ",  date('d M Y',$unixtime), " - ", time()-604800, " - ", $result2_row['user_lastvisit'];
				echo "<br>";
			}
	}
};

and here is the output:

User1 - 26 Apr 2005 - 1113956786 - 1114556358
User2 - 25 Apr 2005 - 1113956786 - 1114441924
User3 - 24 Apr 2005 - 1113956786 - 1114391420
User4 - 22 Apr 2005 - 1113956786 - 1114205256
User5 - 25 Feb 2005 - 1113956786 - 1109358813
User6 - 09 Feb 2005 - 1113956786 - 1107967939
User7 - 27 Jan 2005 - 1113956786 - 1106882425

The first four users shouldn't be showing?!?!

If I reverse the sql, it displays all the users correctly.

Please help this PHP nube.

    I'd suggest some parenthesis to start.

    SELECT `username`, `user_lastvisit` FROM `phpbb_users` where (`user_rank` = 1 or `user_rank` = 2 or `user_rank` = 6 or `user_rank` = 5) AND `user_lastvisit` < (unix_timestamp(now()) - 604800) ORDER BY `user_lastvisit` DESC

      doh. Thanks!! It's the simple things sometimes.

        looking at your echo statement you want all the people that were on w/i the last 7 days....

        your logic is wrong for that...

        According to your current select statement you wanted all users with certain ranks where last_visit was less than 7 days ago...

        and thats exactly what you got...

        user - unixts_date - now-7days < last_visit
        User1 - 26 Apr 2005 - 1113956786 - 1114556358
        User2 - 25 Apr 2005 - 1113956786 - 1114441924
        User3 - 24 Apr 2005 - 1113956786 - 1114391420
        User4 - 22 Apr 2005 - 1113956786 - 1114205256
        User5 - 25 Feb 2005 - 1113956786 - 1109358813
        User6 - 09 Feb 2005 - 1113956786 - 1107967939
        User7 - 27 Jan 2005 - 1113956786 - 1106882425

          Originally posted by tekky
          looking at your echo statement you want all the people that were on w/i the last 7 days....

          your logic is wrong for that...

          Actually, I want the people that are not on in the last 7 days.

            Originally posted by tweaky
            Actually, I want the people that are not on in the last 7 days.

            Doh you are right, I missed the In- part of In-active and saw Active... which obviously would have been the inverse of what you wanted then 😉

            :o

              Write a Reply...