«Загрузить больше» Получение еще 10 результатов

У меня работает мой скрипт, но появляется только 1 результат. Что мне нужно добавить, чтобы получить следующие десять результатов из моей базы данных. Я предоставил небольшие части кода, которые, по моему мнению, являются самыми важными для этого.

AJAX

<script type="text/javascript"> $(function() { $('.load_more').live("click",function() { var ID = $(this).attr("id"); if(ID) { $("#load"+ID).html('Loading...'); $.ajax({ type: "POST", url: "include/load_more_home_posts.php", cache: false, dataType: "json", data: { streamitem_id: ID}, cache: false, success: function(response){ $("#articles").prepend("<div id='divider-"+response['streamitem_id']+"'><div class='userinfo'><a href='/profile.php?username="+response['username']+"'><img class='stream_profileimage' style='border:none;padding:0px;display:inline;' border=\"0\" src=\"imgs/cropped"+response['id']+".jpg\" onerror='this.src=\"img/no_profile_img.jpeg\"' width=\"40\" height=\"40\" ></a><div class'delete' style='cursor:pointer;position:relative;top:0px;float:right;padding-right:5px;' onclick=\"delete_('"+response['streamitem_id']+"');\">X</div><a href='/profile.php?username="+response['username']+"'>"+response['first']+" "+ response['middle']+" "+response['last']+"</a><span class='subtleLink'> said</span><br/><a class='subtleLink' style='font-weight:normal;'>"+response['streamitem_timestamp']+"</a><hr>"+response['streamitem_content']+"<div style='height:20px;' class='post_contextoptions'><div id='streamcomment'><a style='cursor:pointer;' id='commenttoggle_"+response['streamitem_id']+"' onclick=\"toggle_comments('comment_holder_"+response['streamitem_id']+"');clearTimeout(streamloop);swapcommentlabel(this.id);\">Write a comment...</a></div><div id='streamlike'><a title='Like "+response['first']+" "+ response['middle']+" "+response['last']+"s status' id='likecontext_"+response['streamitem_id']+"' style='cursor:pointer;' onClick=\"likestatus("+response['streamitem_id']+",this.id);\"><div style='width:50px;' id='likesprint"+response['streamitem_id']+"'>Like</a></div><div style='width:50px;' id='likesprint"+response['streamitem_id']+"'><a title='See who likes "+response['first']+" "+ response['middle']+" "+response['last']+"s status' href='include/likes.php?streamitem_id="+response['streamitem_id']+"' /></a></div></div></form></div><div id='streamdislike'><a id='dislikecontext_"+response['streamitem_id']+"' style='cursor:pointer;' onClick=\"dislikestatus("+response['streamitem_id']+",this.id);\"><div style='width:70px;' id='dislikesprint"+response['streamitem_id']+"'>Dislike</a></div><div style='width:70px;' id='dislikesprint"+response['streamitem_id']+"'></div></div></form><div class='stream_comment_holder' style='display:none;' id='comment_holder_"+response['streamitem_id']+"'><div id='comment_list_"+response['streamitem_id']+"'></div><div class='stream_comment_inputarea'><form id='mycommentform' method='POST' class='form_statusinput'>\ <input type='hidden' name='streamidcontent' id='streamidcontent' value='"+response['streamitem_id']+"'>\ <input type='input' name='commentingcontents' id='commentingcontents' placeholder='Say something' autocomplete='off'>\ <input type='submit' id='button' value='Feed'><br/></div></div>").show(); // remove the previous load more link $("#load"+ID).remove(); } }); } return false; }); }); </script> 

LOAD_MORE_HOME_POSTS

  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> в  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> список  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> в  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> в список  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> в список  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> в список  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> в список  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> в список  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> в список  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> в список  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> в список  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> в список  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> в список  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> в список  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> список  <?php session_start(); include("rawfeeds_load.php"); // get the article ID from ajax POST if (isset($_POST['streamitem_id']) && $_POST['streamitem_id'] != "") { $lastID = mysqli_real_escape_string($mysqli,$_POST['streamitem_id']); $following_string=mysqli_real_escape_string($mysqli,$_SESSION['id']); $sql_follows = "SELECT * FROM friends WHERE user1_id=".$following_string." AND status=2 OR user2_id=".$following_string." AND status=2"; $query_follows=mysqli_query($mysqli, $sql_follows) or die("Error finding friendships"); if($query_follows){ $friendlist="(".$_SESSION['id'].","; $t=0; while($follow=mysqli_fetch_array($query_follows)) { if($follow['user1_id']==$_SESSION['id']){ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user2_id']; }else{ if($t>0){ $friendlist=$friendlist.","; } $friendlist=$friendlist. $follow['user1_id']; } $t=$t+1; } $friendlist=$friendlist.")"; } //STREAMDATA $badcall = "(".mysqli_real_escape_string($mysqli,$_SESSION['id']).",)"; if($friendlist==$badcall){ $friendlist="(".mysqli_real_escape_string($mysqli,$_SESSION['id']).")"; } if(isset($_GET['limit'])){ $sqllimit = $_GET['limit']; }else{ $sqllimit = 20; } $following_string = mysqli_real_escape_string($mysqli,$_SESSION['id']); $call="SELECT * FROM streamdata WHERE streamitem_id < '$lastID' AND streamitem_target=".$following_string." OR streamitem_creator=".$following_string." OR streamitem_creator IN ".$friendlist." AND streamitem_target IN ".$friendlist." ORDER BY streamitem_id DESC LIMIT 10"; $chant= mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' => Agotime($resultArr['streamitem_timestamp']) ); } $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['comment_id'] = $resultArr['comment_id']; $json['comment_content'] = $resultArr['comment_content']; $json['comment_poster'] = $resultArr['comment_poster']; $json['comment_datetime'] = Agotime($resultArr['comment_datetime']); $json['comment_streamitem'] = $resultArr['comment_streamitem']; $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $resultArr = mysqli_fetch_assoc($check1); $json['username'] = $resultArr['username']; $json['id'] = $resultArr['id']; $json['first'] = $resultArr['first']; $json['middle'] = $resultArr['middle']; $json['last'] = $resultArr['last']; echo json_encode($json); } ?> 

Прямо сейчас вы не перебираете свой результирующий набор, и поэтому вы получаете только одну строку. Попробуйте следующее, которое разбивает ваш массив $json на три массива (потоки, комментарии, пользователи), которые, в свою очередь, являются массивами (по одному для каждой строки). Обратите внимание, что вам придется соответствующим образом изменить код jQuery.

 /***** STREAMS *****/ $chant = mysqli_query($mysqli, $call) or die(mysqli_error($mysqli)); $json = array(); $json['streams'] = array(); while ($resultArr = mysqli_fetch_assoc($chant)) { $arr = array(); $arr['streamitem_id'] = $resultArr['streamitem_id']; $arr['streamitem_content'] = $resultArr['streamitem_content']; $arr['streamitem_timestamp'] = Agotime($resultArr['streamitem_timestamp']); $json['streams'][] = $arr; } /***** COMMENTS *****/ $check = "SELECT comment_id, comment_datetime, comment_streamitem, comment_poster, comment_content FROM streamdata_comments WHERE comment_poster=".$following_string." ORDER BY comment_datetime DESC"; $check1 = mysqli_query($mysqli,$check); $json['comments'] = array(); while ($resultArr = mysqli_fetch_assoc($check1)) { $arr = array(); $arr['comment_id'] = $resultArr['comment_id']; $arr['comment_content'] = $resultArr['comment_content']; $arr['comment_poster'] = $resultArr['comment_poster']; $arr['comment_datetime'] = Agotime($resultArr['comment_datetime']); $arr['comment_streamitem'] = $resultArr['comment_streamitem']; $json['comments'][] = $arr; } /***** USERS *****/ $check = "SELECT * FROM users WHERE id=".$following_string.""; $check1 = mysqli_query($mysqli,$check); $json['users'] = array(); while ($resultArr = mysqli_fetch_assoc($check1)) { $arr = array(); $arr['username'] = $resultArr['username']; $arr['id'] = $resultArr['id']; $arr['first'] = $resultArr['first']; $arr['middle'] = $resultArr['middle']; $arr['last'] = $resultArr['last']; $json['users'][] = $arr; } echo json_encode($json); 

Что касается jQuery, я просто покажу вам пример того, что вы можете сделать, потому что я не знаю, как выглядит ваш DOM, и ваш код не так прост. Вы должны иметь возможность обновлять свой код без каких-либо серьезных головных болей.

 success: function(response) { // Streams $.each(response.streams, function(i, stream) { alert(response.streams[i].streamitem_id); }); // Comments $.each(response.comments, function(i, comment) { alert(response.comments[i].comment_id); }); // Users $.each(response.users, function(i, user) { alert(response.users[i].id); }); } 

Изменить: в приведенном выше примере было бы лучше использовать прямые, comment и user переменные напрямую, а не смотреть на массивы в позиции i.

Кроме того, я бы предложил вам разделить скрипт на несколько сценариев, которые имеют более узкий фокус.

Попробуй это:

 $json = array(); while($resultArr = mysqli_fetch_assoc($chant)) { $json[] = array( 'streamitem_id' => $resultArr['streamitem_id'], 'streamitem_content' => $resultArr['streamitem_content'], 'streamitem_timestamp' = Agotime($resultArr['streamitem_timestamp']) ); }