Solved

php to print for 4 copy just only header change

Posted on 2008-06-17
5
181 Views
Last Modified: 2013-12-12
The code below is work I wan to change  But i want 4 copy that is the same only change is header  

Tax Invoice, receipt, Taxinvoice(copy), Taxinvoice(GOV)  taxinvoce for customer and for my shop and for goverment but the detail is the same  

How can I make php generate 4 page that can print on a4 or If can print in A5 i am very happy
Thank you
<?php require_once('../Connections/localhost.php'); 

 

$maxRows_Recordset1 = 5;

$pageNum_Recordset1 = 0;

 

$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

 

mysql_select_db($database_localhost, $localhost);

$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

?>

<!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; }

-->

</style>

</head>

 

<body>

<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>

<p>&nbsp;</p>

</body>

</html>

<?php

mysql_free_result($Recordset1);

?>

Open in new window

0
Comment
Question by:teera
  • 3
  • 2
5 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 21801108
You could have four "pages" in your html, by using

<div class="page">
  Page 1 content here
</div>
<div class="page">
  Page 2 content here
</div>
<div class="page">
  Page 3 content here
</div>
<div class="page">
  Page 4 content here
</div>


Then use css's:
<style type="text/css">
div.page { page-break-aftere:always}
</style>
0
 

Author Comment

by:teera
ID: 21801188
i try but when print pre view it separate in the middle of content
<div class="page">

  <?php require_once('../Connections/localhost.php'); 

 

$maxRows_Recordset1 = 5;

$pageNum_Recordset1 = 0;

 

$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

 

mysql_select_db($database_localhost, $localhost);

$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

?>

<!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; }

-->

</style>

</head>

 

<body>

<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>

<p>&nbsp;</p>

</body>

</html>

<?php

mysql_free_result($Recordset1);

?> 

</div>

<div class="page">

<?php require_once('../Connections/localhost.php'); 

 

$maxRows_Recordset1 = 5;

$pageNum_Recordset1 = 0;

 

$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

 

mysql_select_db($database_localhost, $localhost);

$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

?>

<!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; }

-->

</style>

</head>

 

<body>

<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>

<p>&nbsp;</p>

</body>

</html>

<?php

mysql_free_result($Recordset1);

?> 

</div>

<div class="page">

<?php require_once('../Connections/localhost.php'); 

 

$maxRows_Recordset1 = 5;

$pageNum_Recordset1 = 0;

 

$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

 

mysql_select_db($database_localhost, $localhost);

$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

?>

<!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; }

-->

</style>

</head>

 

<body>

<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>

<p>&nbsp;</p>

</body>

</html>

<?php

mysql_free_result($Recordset1);

?> 

</div>

<div class="page">

<?php require_once('../Connections/localhost.php'); 

 

$maxRows_Recordset1 = 5;

$pageNum_Recordset1 = 0;

 

$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

 

mysql_select_db($database_localhost, $localhost);

$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

?>

<!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; }

-->

</style>

</head>

 

<body>

<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>

<p>&nbsp;</p>

</body>

</html>

<?php

mysql_free_result($Recordset1);

?> 

</div>
 
 
 

<style type="text/css">

div.page { page-break-aftere:always}

</style>

Open in new window

rows.GIF
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 500 total points
ID: 21801241
Hi,

In regard to html, your structure cannot be:

<div class="page">
<html>
..
</html>
</div>

But should only have a single <html> and <body> tag:

<html>
  <body>
    <div class="page">..</div>
     <div class="page">..</div>
  </body>
</html>

An easier to maintain setup would be to have a single index file, with the 4 pages in their own php files. See the code attached.
Note that I haven't included Page2-Page4 but those are similar to Page1.php

Kind regards

-r-

[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

0
 

Author Comment

by:teera
ID: 21801291
Hi Roonaan
$query_Recordset1 = "SELECT * FROM billingdetail WHERE BilDetRef = 29

in line 40

if i send variable form another page to change value of 29 is it effect to all 4 page
0
 
LVL 49

Expert Comment

by:Roonaan
ID: 21801325
You can move the query definition to the main php and remove it from the separate files. Then all files use the same query and you have only one line to maintain.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP 7 with IIs and SQL Server Windows 2008 Server failed to connect 8 55
MySQL Grouping 2 23
Preventing users manipulating URL strings 10 36
html input type 3 22
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now