darkcarnival Posted March 26, 2006 Share Posted March 26, 2006 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:[code]SELECT * FROM metal_posts WHERE Date>='$last_visit'[/code]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 Link to comment https://forums.phpfreaks.com/topic/5825-creating-a-post-made-since-last-visit-problem/ Share on other sites More sharing options...
ToonMariner Posted March 26, 2006 Share Posted March 26, 2006 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 vistitIt may be that you instead use a join on the tables liek so....[code]<?php$qry = "SELECT `metal_posts`.* FROM `metal_posts`, `user` WHERE `metal_posy`.`Date` >= `user`.`lastlogin` AND `user`.`id` = $_SESSION['id']";$qry = mysql_query($qry);......[/code]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.... Link to comment https://forums.phpfreaks.com/topic/5825-creating-a-post-made-since-last-visit-problem/#findComment-20767 Share on other sites More sharing options...
darkcarnival Posted March 26, 2006 Author Share Posted March 26, 2006 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:[code] 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();}[/code]i might be missing something but i cant think of what that is. if someone here knows, please tell me.thanks. Link to comment https://forums.phpfreaks.com/topic/5825-creating-a-post-made-since-last-visit-problem/#findComment-20769 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.