title: PHP - Loop inside loop second loop runs only once
body: <p>I'm running one while inside another while but the second one is running only one time why and how can I fix it. I have also try with for but running again only once.</p>
  
  <pre><code>$sql = "SELECT DISTINCT season FROM search WHERE link = '$getid' Order by id asc";
  $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
  while ($list = mysql_fetch_assoc($result))
  {
      $season = $list['season'];
      $sql = mysql_query("SELECT * FROM search WHERE link = '$getid' and season = '$season'");
      $episodes = mysql_num_rows($sql);
      echo '1st';
      $sqls = "SELECT * FROM search WHERE link = '$getid' and season = '$season' Order by id asc";
      $results = mysql_query($sqls, $conn) or trigger_error("SQL", E_USER_ERROR);
      while ($lists = mysql_fetch_assoc($results))
      {
          $episode = $lists['episode'];
          echo'2nd';
      }
  }
  </code></pre>