How to slide in only new posts jquery
<p>Hey guys, I'm using jquery to load posts from another page every 5 seconds by using this code:</p>

<pre><code>&lt;script&gt; 
  jQuery(function($){
    $('#loaddiv').show();
  })

  var auto_refresh = setInterval(
  function(){
    $('#loaddiv').hide().load('reload.php').show();
  }, 5000);
&lt;/script&gt;
</code></pre>

<p>And here's reload.php:</p>

<pre><code> &lt;?php
  session_start();

  ini_set('display_errors', 'On');
    error_reporting(E_ALL);

  $mysql=mysql_connect('localhost','***','***');
  mysql_select_db('jmtdy');

  $result=mysql_query("select * from users where username='".$_SESSION['username']."'") or die(mysql_error());
    $dbarray=mysql_fetch_assoc($result);

    $id=$dbarray['id'];
    $result1=mysql_query("select * from friendship where userid='".$id."'") or die(mysql_error());
    $dbarray1=mysql_fetch_assoc($result1);

    $userid=$dbarray1['friendid'];
  $result2=mysql_query("select * from posts where userid='".$userid."' or userid='".$id."' ORDER BY id DESC LIMIT 20") or die(mysql_error());
  if(mysql_num_rows($result2) &gt;=1) {
    while($dbarray2=mysql_fetch_assoc($result2)) {
      echo '&lt;div class="homestatus"&gt;&lt;a class="homeusername" href="account.php?user='.$dbarray2['username'].'"&gt;'
        .$dbarray2['fname'].' '.$dbarray2['lname'].':&lt;a&gt;&lt;p class="homepost"&gt;'
        .$dbarray2['post'].'&lt;/p&gt;&lt;p class="hometime"&gt;'.$dbarray2['time'].'&lt;/p&gt;&lt;/div&gt;';
    }
    }
    else {
        echo '&lt;p class="homestatus"&gt;No new updates from your friends.&lt;/p&gt;';
  }
?&gt;
</code></pre>

<p>It's working perfectly but my question is, how can I slide in the new results sort of how Quora slides in new answers in questions using jquery?</p>

<hr>

<p>Ok I came up with this:</p>

<pre><code>&lt;script&gt; 

  jQuery(function($){
    $('#loaddiv').show();
  })

  var auto_refresh = setInterval(
  function(){
    var timestamp = new Date().getTime() - 5000;
    // get posts for the last 5 seconds only
    var new_posts = $.load('reload.php?time=' + timestamp);
    $('#loaddiv').append(new_posts).show('slow');
  }, 5000);
&lt;/script&gt;
</code></pre>

<p>and this:</p>

<pre><code>&lt;?php   
    session_start();
   ini_set('display_errors', 'On');
    error_reporting(E_ALL);
   $mysql=mysql_connect('localhost','***','***');
   mysql_select_db('jmtdy');
   $result=mysql_query("select * from users where username='".$_SESSION['username']."'") or die(mysql_error());
    $dbarray=mysql_fetch_assoc($result);
    $id=$dbarray['id'];
    $result1=mysql_query("select * from friendship where userid='".$id."'") or die(mysql_error());
    $dbarray1=mysql_fetch_assoc($result1);  
    $userid=$dbarray1['friendid'];
    $time=mysql_real_escape_string($_GET['time']);

   $result2=mysql_query("select * from posts where userid='".$userid."' or userid='".$id."' and time='".$time."' ORDER BY id DESC LIMIT 20") or die(mysql_error());
 if(mysql_num_rows($result2) &gt;=1) {
 while($dbarray2=mysql_fetch_assoc($result2)) {
    echo '&lt;div class="homestatus"&gt;&lt;a class="homeusername" href="account.php?user='.$dbarray2['username'].'"&gt;'.$dbarray2['fname'].' '.$dbarray2['lname'].':&lt;a&gt;&lt;p class="homepost"&gt;'.$dbarray2['post'].'&lt;/p&gt;&lt;p class="hometime"&gt;'.$dbarray2['time'].'&lt;/p&gt;&lt;/div&gt;';
    }
    }
    else {
        echo '&lt;p class="homestatus"&gt;No new updates from your friends.&lt;/p&gt;';
}

?&gt;
</code></pre>

<p>But I get this error:
Notice: Undefined index: time in /var/www/Cliproid/reload.php on line 13</p>
