When is it Counterproductive to Separate PHP and HTML

(EDIT) Please tell me if I am in the wrong forum. Didn’t realize I was not in normal StackOverflow until after I submitted this)

Understanding that it is less load on the server to not have to parse HTML, when does it work the other way, as far as server performance.

The majority of my Web sites are database-driven – often the same cosmetic structure with entirely different information. Separating the HTML, which is minimal compared to the PHP involved, does it come to a point where excessive calls to PHP defeat the performance gained by separating the two? I am totally aware of the possibility that I do not totally understand how PHP processing takes place. I am listing two examples below.

Unless I am misunderstanding how PHP works, in this little bit of code, I am making 5 calls to PHP, whereas the second is only one.

(Please excuse the old mysql. This was just a convenient example)_

Separate

<div class="Filters">
   <?PHP
   $Result = mysql_query( --- Complex query --- );
   if(!$Result){$Error() = "Database Error! (4)";}
   else
   {
      $L = mysql_num_rows($Result);
      $CatItems() = "All";
      while($C=mysql_fetch_array($Result))
      {
         $CatItems() = $C('Cat');
      }
      sort($CatItems);
      $a = $L%2 == 0 ? (int)($L/2) : (int)($L/2)+1;
      ?>
      <div class="2Col">
      <?PHP
      for($x = 0; $x < $a; $x++)
      {
         ?>
         <div class="FilterItem">
            <div class="CriteriaSelect" data-cat="<?PHP echo($CatItems($x));?>"><?PHP echo($CatItems($x))?/>
            <div class="FilterCount">
               <?PHP  
               if($CatItems($x) == "All"){$Rows = $ProgRows;}
               else
               {
                  $CCount = mysql_query( --- Complex query --- );
                  $Rows = mysql_num_rows($CCount);
               }
               echo('('.$Rows.');
               ?>
            </div>
         </div>
      </div>
   </div>

PHP Writing HTML

<?PHP
echo('
<div class="Filters">');
   $Result = mysql_query( --- Complex query --- );
   if(!$Result){$Error() = "Database Error! (4)";}
   else
   {
      $L = mysql_num_rows($Result);
      $CatItems() = "All";
      while($C=mysql_fetch_array($Result))
      {
         $CatItems() = $C('Cat');
      }
      sort($CatItems);
      $a = $L%2 == 0 ? (int)($L/2) : (int)($L/2)+1;
      echo('
      <div class="2Col">');
      for($x = 0; $x < $a; $x++)
      {
         echo('
         <div class="FilterItem">
            <div class="CriteriaSelect" data-cat="'.$CatItems($x).'">'.$CatItems($x).'
            <div class="FilterCount">');
               if($CatItems($x) == "All"){$Rows = $ProgRows;}
               else
               {
                  $CCount = mysql_query( --- Complex query --- );
                  $Rows = mysql_num_rows($CCount);
               }
               echo('('.$Rows.');
               echo('
            </div>
         </div>
      </div>
   </div>');
   ?>