Jump to content

new posts/ no new posts


runnerjp

Recommended Posts

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.

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' }

 

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 } ?> 

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" />';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.