title: PHP + MySQL suddenly stops the query
body: <p>I can't understand how and why my <strong>mysql_query</strong> command stops it's execution.
  There are two arrays I work with:</p>
  
  <ol>
  <li>routersTree (includes about 100 rows)</li>
  <li>dates (includes about 30 cells)</li>
  </ol>
  
  <p>Here the code:</p>
  
  <pre><code>while ($i &lt;= count($routerTree)){
      $currentRouter = $routerTree["router_$i"];
      echo "&lt;td&gt;$i&lt;/td&gt;";
      for ($j = 0; $j &lt; count($dates); $j++) { 
          $sql = "SELECT indications.id_device FROM indications LEFT JOIN routers ON indications.id_device = routers.id_device WHERE routers.id_router = $currentRouter[id_router] AND date(indications.dateField) = '$dates[$j]' ORDER BY routers.id_device";
          if ($res = mysql_num_rows(mysql_query($sql))) {
              echo "&lt;td&gt;$res&lt;/td&gt;";
              }
          else {
              echo "&lt;td&gt;error&lt;/td&gt;";
              }
          }
      }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/7a972.jpg" alt="enter image description here"></p>
  
  <p>It stops my cycle after 18-th row, but there are about 82 cycles more to do.
  My guess is, that there is a small timeout for mysql_query command.
  Any help would be appreciate.</p>