title: Page Break After Specific Number Of Rows
body: <p>I am developing a voucher printing application that prints serial numbers and pins from a MySQL table and displays them in a page.</p>
  
  <p>The php code displays two records per row..with being in a separate column i.e two columns displayed side by side
  Due to the format of the page (two records per row)..i can not display each record in a seperate table. Rather all records are contained in a "general" table.</p>
  
  <p>The voucher printing requires two rows to be displayed on each page.</p>
  
  <p>I implemented a "page-break-after: always" style to each row not divisble by two, but page break is not showing. My code is shown below:</p>
  
  <pre><code>        $aray=array();
    while($row=mysqli_fetch_array($sql_res))
    { 
   $aray[]=$row;
    }
  $nr_elm=count($aray);
  $table='&lt;table width=100%&gt;&lt;tr&gt;';
  $nr_col=2;
  if($nr_elm&gt;0)
  { 
  $p=1;//This is the row counter
  for($i=0;$i&lt;$nr_elm;$i++)
  {
  
      $table.='&lt;td&gt;&lt;div  style="border: 2px dashed #000;" &gt;&lt;div id="image" style="float:left;"&gt;
     '.$p.' &lt;img src="crswb1.png" height=80 width=60 /&gt;
  &lt;/div&gt;&lt;div id="texts" style="  float: none;
  margin-left:60px;"&gt; 
     &lt;p&gt;&amp;nbsp;Amount:'.$aray[$i]['amount'].' &lt;/p&gt;&lt;p&gt;&amp;nbsp; Pin:17263648409&lt;/p&gt;&lt;p&gt;&amp;nbsp; Serial:5374748548
  &lt;/div&gt;&lt;/div&gt;&lt;/td&gt;';
  
  $col_to_add=($i+1)%$nr_col;
  if($col_to_add==0)
  {
      if($p % 2 == 0) {
  
        $table.="&lt;tr style='page-break-after:always'&gt;";
  
      }
  
      $table.='&lt;/tr&gt;&lt;tr&gt;';
      $p++;
              }
  }
  
  }
  
  $table.='&lt;/tr&gt;&lt;/table&gt;';
  $table=str_replace('&lt;tr&gt;&lt;/tr&gt;','',$table);
  echo $table;
       ?&gt;
  </code></pre>
  
  <p>I viewed the page source and the "page break" style is showing for the neccessary row, as seen below</p>
  
  <pre><code> &lt;tr style='page-break-after:always'&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;div  style="border: 2px dashed #000;" &gt;&lt;div id="image" style="float:left;"&gt;
     3 &lt;img src="crswb1.png" height=80 width=60 /&gt;
  &lt;/div&gt;&lt;div id="texts" style="  float: none;
  </code></pre>
  
  <p>How can i ensure that the page break is displayed so that i can print only two rows per page?..Thanks.</p>