runnerjp Posted October 24, 2008 Share Posted October 24, 2008 when a user logs onto a forum how could i show then/find out that a new post has been made since there last visit... would i have to log all there visted links or is this something far easyer Quote Link to comment https://forums.phpfreaks.com/topic/129963-new-posts-no-new-posts/ Share on other sites More sharing options...
JonnoTheDev Posted October 24, 2008 Share Posted October 24, 2008 You would obviously store the time of login for that user. Possibly if tracking the user you store the last click time. Each post has a creation time so displaying new posts is simply a case of retreiving all posts greater than the users last click time. Quote Link to comment https://forums.phpfreaks.com/topic/129963-new-posts-no-new-posts/#findComment-673766 Share on other sites More sharing options...
runnerjp Posted October 24, 2008 Author Share Posted October 24, 2008 ok little bit stuck ... ok i store the users last post time exct in db... so im not sure how to put this together... ok so this would get the time of users last post... $getlastpost="SELECT * FROM users WHERE ID = '$uid'"; //getting replies $getlastpost2=mysql_query($getlastpost) or die(mysql_error()."Could not get replies"); while($getlastpost3=mysql_fetch_array($getlastpost2)) $getlastpost3['last_post']; and i allready get the last post by <?php $getthreads="Select * from forumtutorial_posts where parentid='0' and forum = 'general' ORDER BY lastrepliedto DESC LIMIT 1"; $getthreads2=mysql_query($getthreads) or die("Could not get threads"); while($getthreads3=mysql_fetch_array($getthreads2)) { $getthreads3[title]=strip_tags($getthreads3[title]); $getthreads3[author]=strip_tags($getthreads3[author]); $dbtime=$getthreads3['lastrepliedto']; $time = date("F j Y, g:i a", $dbtime); echo $time;?><br> Last post by <b><? echo $getthreads3[lastposter]?> </b> <? } ?> so how would i find it that if (the last post is more then last logged in) { echo 'more' } else{ echo ' non new' } Quote Link to comment https://forums.phpfreaks.com/topic/129963-new-posts-no-new-posts/#findComment-674014 Share on other sites More sharing options...
runnerjp Posted October 25, 2008 Author Share Posted October 25, 2008 bmp Quote Link to comment https://forums.phpfreaks.com/topic/129963-new-posts-no-new-posts/#findComment-674237 Share on other sites More sharing options...
runnerjp Posted October 26, 2008 Author Share Posted October 26, 2008 bmp Quote Link to comment https://forums.phpfreaks.com/topic/129963-new-posts-no-new-posts/#findComment-674940 Share on other sites More sharing options...
runnerjp Posted October 26, 2008 Author Share Posted October 26, 2008 ok i have got it working but the code is large lol can any1 show me how i could cut it down so its much less coding or is this not possible? <?php $getlastpost="SELECT * FROM users WHERE ID = '1'"; //getting replies $getlastpost2=mysql_query($getlastpost) or die(mysql_error()."Could not get replies"); while($getlastpost3=mysql_fetch_array($getlastpost2)) $dbtime = $getlastpost3['last_post']; $time = date("F j Y, g:i a", $dbtime); echo $time; ?> <br> <?php $getthreads="Select * from forumtutorial_posts where parentid='0' and forum = 'general' ORDER BY lastrepliedto DESC LIMIT 1"; $getthreads2=mysql_query($getthreads) or die("Could not get threads"); while($getthreads3=mysql_fetch_array($getthreads2)) { $getthreads3[title]=strip_tags($getthreads3[title]); $getthreads3[author]=strip_tags($getthreads3[author]); $dbtime=$getthreads3['lastrepliedto']; $time2 = date("F j Y, g:i a", $dbtime); echo $time2; } if ($time <= $time2){ ?> <img src="http://www.runningprofiles.com/images/postforum.gif" alt="My" /> <?php } else { ?> <img src="http://www.runningprofiles.com/images/postforum.jpg" alt="My" /> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/129963-new-posts-no-new-posts/#findComment-674945 Share on other sites More sharing options...
runnerjp Posted October 27, 2008 Author Share Posted October 27, 2008 ok i have chnaged the code even more now... <?php $getthreads_result=mysql_query("Select * from forumtutorial_posts where parentid='0' and forum = 'general' ORDER BY lastrepliedto DESC LIMIT 1") or die("Could not get threads"); while($getthreads=mysql_fetch_array($getthreads_result)) $getlastpost=mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE ID = '1'")); if ($getlastpost['last_post'] <= $getthreads['lastrepliedto']) { echo '<img src="http://www.runningprofiles.com/images/postforum.gif" alt="My" />'; } else { echo '<img src="http://www.runningprofiles.com/images/postforum.jpg" alt="My" />'; } ?> but for some reaosn it ALWAYS shows echo '<img src="http://www.runningprofiles.com/images/postforum.jpg" alt="My" />'; Quote Link to comment https://forums.phpfreaks.com/topic/129963-new-posts-no-new-posts/#findComment-675463 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.