title: PHP mysql data not retrieving from last id
body: <p>I'm developing one API in php to display data on android app from my database using JSON.</p>
  
  <p>In my app I want to display 20 records first, after display again 20 records once user scroll to top.
  I'm requesting the last id of the record from app to show next 20 records from last id.</p>
  
  <p>Here is my code</p>
  
  <pre><code>&lt;?php
  $last_movie = 0;
  $genre = $_REQUEST['genre'];
  $last_movie = $_REQUEST['lastid'];
  
  require_once("connect.php");
  $myArray = array();
  
  if($last_movie == 0)
  {
      $result = $conn-&gt;query("SELECT * FROM my_movies WHERE genre = '$genre' ORDER BY year DESC LIMIT 20");
  }
  else
  {
       $result = $conn-&gt;query("SELECT * FROM my_movies WHERE genre = '$genre' ORDER BY year LIMIT ".$last_movie.",20");
  
  }
  
  if ($result) {
  
      while($row = $result-&gt;fetch_array(MYSQL_ASSOC)) {
              $myArray[] = $row;
      }
      echo json_encode($myArray);
  }
  
  $result-&gt;close();
  $conn-&gt;close();
  
  
  
  ?&gt;
  </code></pre>
  
  <p>I'm getting values in some genres, but sometimes it show empty JSON.
  I tried with this url
  <a href="http://freemodedapk.com/bobmovies/by_genre.php?genre=Action" rel="nofollow noreferrer">http://freemodedapk.com/bobmovies/by_genre.php?genre=Action</a></p>
  
  <p>its working , whenever I try from last id
  <a href="http://freemodedapk.com/bobmovies/by_genre.php?genre=Action&amp;lastid=4714" rel="nofollow noreferrer">http://freemodedapk.com/bobmovies/by_genre.php?genre=Action&amp;lastid=4714</a></p>
  
  <p>It returns empty JSON. I have values in database.</p>
  
  <hr>
  
  <p>But some genres working fine
  <a href="http://freemodedapk.com/bobmovies/by_genre.php?genre=Drama" rel="nofollow noreferrer">http://freemodedapk.com/bobmovies/by_genre.php?genre=Drama</a>
  <a href="http://freemodedapk.com/bobmovies/by_genre.php?genre=Drama&amp;lastid=865" rel="nofollow noreferrer">http://freemodedapk.com/bobmovies/by_genre.php?genre=Drama&amp;lastid=865</a></p>
  
  <p>I have total 4858 records in the database with all genres.</p>
  
  <p>Anybody can help me to fix empty JSON problems in some of genres ?</p>