title: Switching from "if" to "elseif" breaks code
body: <p>I'm using multiple if statements to check a containing div, and output an image based on the container name. The code was working fine until I add a final "else" or change the if's out to elseif and I can't figure out why that's happening. When I try to add the else or elseif, the entire page fails to load. Any idea why this is happening? </p>
  
  <pre><code>            &lt;?php
              if($viewMore['container_type'] == 'Large IMG' || $viewMore['container_type'] == 'Gallery') {
                  $photoSql = "SELECT * FROM  `cms_uploads` WHERE  (`tableName`='site_content' AND `recordNum` = '".$viewMore['num']."' AND `fieldname`= 'large_images') ORDER BY `order`";
                  $photoResult = $database-&gt;query($photoSql);
                  $photoResultNum = $database-&gt;num_rows($photoResult);
  
                  $photoArray = array();
                  while($photoResultRow = $database-&gt;fetch_array($photoResult)) {
                      array_push($photoArray, $photoResultRow);
                  }
  
                  $large = 0; foreach ($photoArray as $photo =&gt; $upload): if (++$large == 2) break;
              ?&gt;
  
                  &lt;img class="features" src="&lt;?php echo $upload['urlPath'] ?&gt;"&gt;
  
              &lt;?php endforeach ?&gt;
              &lt;?php } ?&gt;
  
              &lt;?php
              elseif($viewMore['container_type'] == 'Medium IMG') {
                  $photoSql = "SELECT * FROM  `cms_uploads` WHERE  (`tableName`='site_content' AND `recordNum` = '".$viewMore['num']."' AND `fieldname`= 'small_images') ORDER BY `order`";
                  $photoResult = $database-&gt;query($photoSql);
                  $photoResultNum = $database-&gt;num_rows($photoResult);
  
                  $photoArray = array();
                  while($photoResultRow = $database-&gt;fetch_array($photoResult)) {
                      array_push($photoArray, $photoResultRow);
                  }
  
                  $medium = 0; foreach ($photoArray as $photo =&gt; $upload): if (++$medium == 2) break;
              ?&gt;
  
                  &lt;img class="features" src="&lt;?php echo $upload['urlPath'] ?&gt;"&gt;
  
              &lt;?php endforeach; ?&gt;
              &lt;?php } ?&gt;
  
                        &lt;?php else { ?&gt; SOMETHING HERE &lt;?php } ?&gt;
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Other notes</p>
  
  <p>I've tried wrapping the break; in brackets because I thought that piece following the count might be messing with something. Also removing the counter altogether or adding a semi colon after the endforeach didn't help. </p>