如何使自动滚动页面有效

时间:2016-12-20 14:36:57

标签: php mysql

我会努力做到这一点。所以我尝试使用新内容进行页面自动滚动,但是我试图使新更新的内容像其他内容一样有效。 这是我的代码:



           goNextConnection();
function goNextConnection() {
     var recent = 1;
     var scrollNote = $('.scrollNote').hide();
    $('#nextConn').click(function() {
        recent++;
        var username = $(this).attr('name');
        $('.scrollNote').show();
      $.post("connautoscroll.php", {recent: recent, username: username}, function(data) {
        if(data.trim().length == 0){
            $(".scrollNote").text("No more records!");
            $('#nextConn').prop("disabled", true);
        }
            $('.connNet section:last').after(data);
         // $("html, body").animate({scrollTop: $("#nextConn").offset().top}, 800);
          $('.scrollNote').hide();
      });
      return false;
    });
}




确定。当我点击按钮时,这实际上会自动更新包含新内容的页面。但这就是让我发疯的原因。 我碰巧像下面那样对页面更新程序进行编码,但是当我想发表评论时,它会附加新文本,将其保存在数据库中,但在重新加载页面时,它不会在数据库上显示注释。



if( isset($_POST['recent']) && isset($_POST['username']) )
{
    $recent = $_POST['recent'];
    $username = trim($_POST['username']);
    $item_per_page = "3";
    $position = (($recent - 1) * $item_per_page);

    $stmt = $connection->prepare("SELECT * FROM connection ORDER BY id DESC LIMIT ?, ?");
    $stmt->bind_param('ds', $position, $item_per_page);
    $stmt->execute();
    $connMessages =$stmt->get_result();
  while($run_post = $connMessages->fetch_array(MYSQLI_ASSOC))
  {
    $post_id  = $run_post['id'];
    $name     = $run_post['name'];
    $text     = $run_post['about'];
    $text     = $run_post['about'];
    $text     = $run_post['about'];
    $folder   = $run_post['directory'];
    $user     = $run_post['username'];
    $date     = $run_post['date'];
    $src      = $folder.$name;
    $time     = $run_post['time'];
    $datetime = $date.$time;

      $stmt = $connection->prepare("SELECT * FROM upload WHERE username = ?");
      $stmt->bind_param('s', $user);
      $stmt->execute();
      $get_query =$stmt->get_result();
         $run_pic2 = $get_query->fetch_array(MYSQLI_ASSOC);
         $imgName = $run_pic2['imagename'];
         $imgDir  = $run_pic2['content'];
         $src2    = $imgDir.$imgName;
    if($get_query)
    {
      $stmt = $connection->prepare("SELECT * FROM comments WHERE post_id = ? AND date >= DATE_SUB(NOW(), INTERVAL 16 DAY) ");
      $stmt->bind_param('s', $post_id);
      $stmt->execute();
      $chatMsg =$stmt->get_result();

    while($getChat2 = $chatMsg->fetch_array(MYSQLI_ASSOC))
    {
         $sender  = $getChat2['username'];
         $comment = $getChat2['comment'];
         $time2   = $getChat2['time'];
         $date2   = $getChat2['date'];
         $timeAgo = timeAgo($datetime);
 echo <<<END
   <section class='offers'>
        <div id='name'> $user &nbsp;|&nbsp; $timeAgo&nbsp;at&nbsp;$time
        <div class='disImg'>
           <img src=' $src2 ' class='connDisImg' alt='poster image' >
        </div>
        </div>
        <div id='telWhat'> $text </div>
        <div id='what'><img class='whatImg' alt='Image' src=' $src '></div>
        <div class='commentDiv'>
           <div class='group commentName'><b>$sender</b>-<em>$comment</em></div>
        </div>
          <input type='text' username=' $username ' post_id=' $post_id ' class='tellWhat' name='comment' placeholder='What&rsquo;d you think?'>
    </section>
END;
    }
    }else{
      echo "Error encounted";
   }
&#13;
&#13;
&#13; 请快速帮助将非常感谢。谢谢。

0 个答案:

没有答案