Jump to content


Photo

creating a post made since last visit problem


  • Please log in to reply
2 replies to this topic

#1 darkcarnival

darkcarnival
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 26 March 2006 - 02:08 AM

hi,

on a news program i made i want to allow my members to see what new articles were made since they last visited the site. pretty much what i want to do is exactly how phpbb and other bbs programs do.

now looking at them i applied the same method but it doesnt seem to work.

first off i added a colume last_visit which would have the last time they visited the site(in time())

then i made it do a search with the following query:

SELECT * FROM metal_posts WHERE Date>='$last_visit'

now doing it that displayed 0 results everytime no matter what. changed >= to <= just displayed all of the news articles.

so question is, what am i doing wrong?

to let you know all the dates on my program are in time() format so format issue isnt the problem here.

thanks

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 26 March 2006 - 03:27 AM

make sure you ARE using a timestamp for both variable types. That is a timestamp for the last login and a tiemstamp for the ews article. Assuming that is all in order, make suer you are assiging a value to last vistit

It may be that you instead use a join on the tables liek so....
<?php
$qry = "SELECT `metal_posts`.* FROM `metal_posts`, `user` WHERE `metal_posy`.`Date` >= `user`.`lastlogin` AND `user`.`id` = $_SESSION['id']";
$qry = mysql_query($qry);
......
Now the field names need to be matched up (unless I am teh best guesser in the world!) but that should not be a problem! and the $_SESSION can be what ever you use to identify the user 9again I assume you use sessions witch may not be the case....
follow me on twitter @PHPsycho

#3 darkcarnival

darkcarnival
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 26 March 2006 - 03:33 AM

actually im using cookies ;)

and i got the problem solved, though now i have another problem.

to solved it i forgot i had to check the read table i made.

now i still have one issue and thats getting the correct number result. tried looping it but it doesnt seem to want to do that.

here is how im doing that:

while ($row = mysql_fetch_assoc($search_result)) {

$db->run = "select * from post_read WHERE Topic='$row[tid]' and user='$logged_user'";
$t_num = $db->num_results();
$db->close();
}

i might be missing something but i cant think of what that is. if someone here knows, please tell me.

thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users