Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

page breake separate page php css

All 4 page are the same code but when i try to prinpreview with fire fox  it not separate into 4 page

How can i make it separate when print


Page1.php,Page2.php,Page3.php Page4.php are the same code
[Main.php]
<?php
 
require_once('../Connections/localhost.php'); 
mysql_select_db($database_localhost, $localhost);
 
$maxRows_Recordset1 = 5;
$pageNum_Recordset1 = 0;
 
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
 
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style2 {
        font-size: 14px;
        font-weight: bold;
}
.style3 {color: #000000; font-size: 9px; }
div.page { page-break-aftere:always}
-->
</style>
</head>
 
<body>
	<div class="page"><?php include "Page1.php"; ?></div>
	<div class="page"><?php include "Page2.php"; ?></div>
	<div class="page"><?php include "Page3.php"; ?></div>
	<div class="page"><?php include "Page4.php"; ?></div>
</body>
</html>
 
 
 
[Page1.php]
<?php  
	$query_Recordset1 = "SELECT * FROM billingdetail WHERE BilDetRef = 29 ORDER BY id ASC ";
	$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
	$Recordset1 = mysql_query($query_limit_Recordset1, $localhost) or die(mysql_error());
	$rows_Recordset2 = mysql_num_rows($Recordset1);  //get the number of rows returned here
	 
	$row_Recordset1 = mysql_fetch_assoc($Recordset1);
	$my_counter = 0; // count records read
	?>
<table width="699" border="0">
  <tr>
    <td colspan="2"> <div align="center"><span class="style2">&#3651;&#3610;&#3585;&#3635;&#3585;&#3633;&#3610;&#3616;&#3634;&#3625;&#3637;  TAX INVOICE </span> <em>&#3605;&#3657;&#3609;&#3593;&#3610;&#3633;&#3610;&#3621;&#3641;&#3585;&#3588;&#3657;&#3634;</em></div></td>
  </tr>
  <tr>
    <td width="456" class="style3"><span class="style2">&#3610;&#3619;&#3636;&#3625;&#3633;&#3607; &#3626;&#3617;&#3640;&#3618; &#3648;&#3588;&#3648;&#3610;&#3636;&#3657;&#3621; &#3607;&#3637;&#3623;&#3637; &#3592;&#3635;&#3585;&#3633;&#3604;</span></td>
    <td width="233" class="style2"><span class="style3">&#3648;&#3621;&#3586;&#3611;&#3619;&#3632;&#3592;&#3635;&#3605;&#3633;&#3623;&#3612;&#3641;&#3657;&#3648;&#3626;&#3637;&#3618;&#3616;&#3634;&#3625;&#3637;&#3629;&#3634;&#3585;&#3619; 3 821 018544 </span></td>
  </tr>
  <tr>
    <td class="style3">45/1-2 &#3627;&#3617;&#3641;&#3656; 1 &#3605;&#3635;&#3610;&#3621;&#3649;&#3617;&#3656;&#3609;&#3657;&#3635; &#3629;&#3635;&#3648;&#3616;&#3629;&#3648;&#3585;&#3634;&#3632;&#3626;&#3617;&#3640;&#3618; &#3592;&#3633;&#3591;&#3627;&#3623;&#3633;&#3604;&#3626;&#3640;&#3619;&#3634;&#3625;&#3598;&#3619;&#3660;&#3608;&#3634;&#3609;&#3637;&#3650;&#3607;&#3619;.(077) 425004-5 Fax &#3605;&#3656;&#3629; 18 </td>
    <td class="style2">&#3648;&#3621;&#3586;&#3607;&#3637;&#3656;</td>
  </tr>
  <tr>
    <td class="style3">&#3609;&#3634;&#3617; Name/&#3607;&#3637;&#3656;&#3629;&#3618;&#3641;&#3656; Address</td>
    <td class="style2">&#3623;&#3633;&#3609;&#3607;&#3637;&#3656;</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>
<table width="692" border="0">
  <tr>
    <td width="10">unitit</td>
    <td><div align="center">Description</div></td>
    <td width="70">unit/price</td>
    <td width="70">total</td>
  </tr>
  <?php 
  do { $my_counter++; // number of recors processed
  $my_BilDetQua = $row_Recordset1['BilDetQua']; 
  $my_BilDetProName = $row_Recordset1['BilDetProName']; 
  $my_BiDelPrice = $row_Recordset1['BiDelPrice']; 
  $my_total = $my_BilDetQua * $my_BiDelPrice 
  ?>
    <tr>
      <td><?php echo $my_BilDetQua; ?></td>
      <td><?php echo $my_BilDetProName; ?></td>
      <td><?php echo $my_BiDelPrice; ?></td>
      <td><?php echo $my_total; ?></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); 
 
 echo "no of records initial $rows_Recordset2 / in the loop $my_counter<br>";
if($rows_Recordset2 < 5 ){
 
$counter = 5 - $rows_Recordset2;  //get the times you want a particular row to be repeated
 echo " counter = ".$counter;
for($rowct = 1; $rowct < $counter; $rowct++){
echo "
<tr>
    <td>&nbsp;<?=$rowct?></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    
  </tr>
<? php // NOTE: THIS IS MISSING IN ALL CODES POSTED ";
 
   }    // end of for loop here
 
}  //end of if loop here
        
        
        ?>
  <tr>
    <td colspan="3">remark</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" class="style2">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<?php mysql_free_result($Recordset1); ?>

Open in new window

rows.GIF
0
teera
Asked:
teera
  • 3
  • 2
1 Solution
 
hieloCommented:
The browser does not know that you are using X number of files. The browser just sees ALL the html code you send it, so it does not differentiate between files. To the browser it is a SINGLE "file".
0
 
teeraAuthor Commented:
hi hielo
I wan to make a invoice  with the same for 4 copy , for me ,for customer,for goverment (it a little bit different in title of each )

I want to print it with browser and I want when print it separate into 4 pages
0
 
hieloCommented:
If I understand you correctly, you want to "push" the pages so that they are printed on separate pages. If so, then try the code below. If the page don't quite start at the top of the page, adjust the line-height within the @media print section for the respective breaker div until it is positioned where you want it.

 
<?php
 
require_once('../Connections/localhost.php'); 
mysql_select_db($database_localhost, $localhost);
 
$maxRows_Recordset1 = 5;
$pageNum_Recordset1 = 0;
 
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
 
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
@media screen{
{
	#breaker1,#breaker2,#breaker3{display:none;}
	.style2 {
        font-size: 14px;
        font-weight: bold;
	}
	.style3 {color: #000000; font-size: 9px; }
	div.page { page-break-aftere:always}
}
 
@media print{
	#breaker1,#breaker2,#breaker3{display:block;}
	#breaker1{
		line-height:15em;
	}
	#breaker2{
		line-height:15em;
	}
	#breaker3{
		line-height:15em;
	}
}
</style>
 
</head>
 
<body>
<body>
	<div class="page"><?php include "Page1.php"; ?></div>
	<div id="breaker1">&#160;</div>
	<div class="page"><?php include "Page2.php"; ?></div>
	<div id="breaker2">&#160;</div>
	<div class="page"><?php include "Page3.php"; ?></div>
	<div id="breaker3">&#160;</div>
	<div class="page"><?php include "Page4.php"; ?></div>
</body>
</body>
</html>

Open in new window

0
 
teeraAuthor Commented:
Hi hielo
it still not separate please help
print.JPG
0
 
hieloCommented:
You need to "play" with the line-height values:
line-height:25em

until you get your results. I cannot give you the right value because I don't know how much data there is per page. If anything add !important to the definitions:

@media print{
      #breaker1,#breaker2,#breaker3{display:block;}
      #breaker1{
            line-height:25em !important;
      }
      #breaker2{
            line-height:35em !important;
      }
      #breaker3{
            line-height:45em !important;
      }
}
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now