title: Why does the loop execute only once?
body: <p>I have the following small code which manipulate tweets data. I expect my loop to iterate 10 times. However, what happens is that it <strong>iterates only once</strong> and then exits, <em>with no sign of any error</em> relating to MySQL or otherwise.</p>
  
  <pre><code>$query = "select data from tweets where `screen_name` = 'username' limit 10";
  $tweetsq = mysqli_query($mysqli, $query) or die(mysqli_error($mysqli));
  $tweets = mysqli_fetch_assoc($tweetsq);
  $tweets_count = mysqli_num_rows($tweetsq);
  echo $tweets_count . '&lt;br /&gt;'; //See output
  
  $count = 0;
  foreach ($tweets as $raw_tweet) {
      $tweet = json_decode($raw_tweet);
      $tweet_id = $tweet-&gt;id_str;
      $is_reply = (isset($tweet-&gt;in_reply_to_screen_name) &amp;&amp; strlen($tweet-&gt;in_reply_to_screen_name) &gt; 0) ? 1 : 0;
      $is_retweet = (isset($tweet-&gt;retweeted_status) &amp;&amp; $tweet-&gt;retweeted_status != '') ? 1 : 0;
      $entity_holder = array();
      $has_hashtag = $has_url = $has_mention = $has_media = 0;
      foreach ($tweet-&gt;entities as $type =&gt; $entity) {
          if (is_array($entity) &amp;&amp; count($entity) &lt; 1) {
              //continue;
          } else {
              $entity = array_pop($entity);
              switch ($type) {
                  case 'hashtags' : $has_hashtag = 1; break;
                  case 'urls' :  $has_url = 1; break;
                  case 'user_mentions' : $has_mention = 1; break;
                  case 'media' : $has_media = 1; break;
                  default :
  
              }
          }
      }
      echo 'Updating recorde... &lt;br /&gt;';
      $query = "UPDATE tweets SET is_reply='" . $is_reply . "' , is_retweet='" . $is_retweet . "', has_hashtag='" . $has_hashtag . "', has_url='" . $has_url . "', has_mention='" . $has_mention . "', has_media='" . $has_media . "' WHERE tweet_id='" . $tweet_id . "'";
      $result = mysqli_query($mysqli, $query) or die(mysqli_error($mysqli));
      var_dump($result); //See output
      $count++;
      echo '&lt;br /&gt;';
  }
  echo $count;
  </code></pre>
  
  <p><strong>Output</strong>:</p>
  
  <pre><code>10 //This is the value of $tweets_count
  Updating recorde... 
  bool(true) //The result of the UPDATE query
  1 //The value of $count at the end of script. It SHOULD be 10
  </code></pre>