title: AJAX Json get data from PHP with for loop
body: <p>I have got this AJAX</p>
  
  <pre><code>$.ajax({
      type: "GET",
      url: '../connect.php',
      data: "OrB=" + ajaxsend+"&amp;&amp;IOr="+i,
      success: function(data)
      { 
          var x = $.parseJSON(data);
          for (var i = 0; i &lt;= 4; i++) {
              var el='&lt;div class="Ordb"&gt;\
              &lt;img src="../users/'+x[i][0]+'"&gt;\
              &lt;span&gt;'+x[i][1]+'&lt;/span&gt;\
              &lt;span class="s2"&gt;'+x[i][2]+'&lt;/span&gt;\
              &lt;/div&gt;'
              $(".F_W_comments").children().remove();
              $(".F_W_comments").html(el);
          } 
      }
  });
  </code></pre>
  
  <p>And this php</p>
  
  <pre><code>if (isset($_GET['OrB'])) {
      $OB=$_GET['OrB'];
      $I=$_GET['IOr'];
      if ($OB=='OO') {
          $OB='`Date` ASC';
      }else if ($OB=='No') {
          $OB='`Date` DESC';
      }
      $query=$con-&gt;query("SELECT id,comment FROM uploads WHERE Rand='$I'");
      $row=$query-&gt;fetch_row();
      $Commentsq=$con-&gt;query("SELECT * FROM comments WHERE Post_id='$row[0]' ORDER BY $OB LIMIT 4") or die($con-&gt;error);
      $commenters = array();
      while ($CommentRow=$Commentsq-&gt;fetch_row()) {
          $CommenterPp=$con-&gt;query("SELECT Profile_pic FROM user_opt WHERE Username='$CommentRow[3]'");        
          $CommenterPicture=$CommenterPp-&gt;fetch_row();
          $CommenterPp=$con-&gt;query("SELECT Username FROM users WHERE Id='$CommentRow[3]'");        
          $CommenterName=$CommenterPp-&gt;fetch_row();
          $commenters[] = array($CommenterPicture,$CommenterName,$CommentRow[1]); 
      }
      echo json_encode($commenters);
  }
  </code></pre>
  
  <p>My problem is AJAX gives me error in console</p>
  
  <pre><code>Uncaught TypeError: Cannot read property '0' of undefined
  </code></pre>
  
  <p>Pointing this line</p>
  
  <pre><code>&lt;img src="../users/'+x[i][0]+'"&gt;\
  </code></pre>
  
  <p>Also i get 1 element returned instead of 4.Have i got any mistake in my code because it is working wrong</p>