如何在php中的新页面上启动新报告

时间:2022-01-03 21:15:30

Hi i have a form which consist three part, namely the letter part, the detail part and the notes part i am able to print the letter report but now i want to start the new report on a new page i mean when a user tries to print the report the letter part should come on a page and the detail part on a newpage which will be A4 for all pages can anybody help me in this? i just want to know how to use while with tables for eg.

嗨我有一个表格,其中包括三个部分,即字母部分,细节部分和笔记部分,我能够打印信件报告,但现在我想在新页面上开始新的报告我的意思是当用户试图打印报告字母部分应该出现在页面上,新页面上的详细信息部分将是A4所有页面可以帮助我吗?我只是想知道如何使用表格,例如。

<?php
echo "table";
while($row= mysql_fetch_array($result)){
echo "<tr>";
echo "<td>$row[data1]</td>";
echo "<td>$row[data2]</td>";
echo "</tr>";
}
echo "</table>";

?>

2 个解决方案

#1


0  

Use page-break-before: always CSS in your table start tag, i.e.

使用page-break-before:表格中的CSS始终开始标记,即

echo '<table style="page-break-before: always">';

Sidenote: MDN suggests that it should be replaced by break-before ( see reference link ), but I DO NOT suggest it, as there is nearly no browser supporting this new CSS3 property.

旁注:MDN建议它应该由break-before替换(参见参考链接),但我不建议,因为几乎没有浏览器支持这个新的CSS3属性。

p.s. I believe the first line should be echo "<table>"; , right?

附:我相信第一行应该是echo“

”; , 对?

Reference : page-break-brefore on MDN

参考:MDN上的分页符

Example:

<?php
echo '<table style="page-break-before: always">';
while($row= mysql_fetch_array($result)){ // Do NOT use mysql_* functions! Use MySQLi / PDO instead
  echo '<tr style="margin-top: 20px;">';
  echo "  <td>$row[data1]</td>";
  echo "  <td>$row[data2]</td>";
  echo "</tr>";
}
echo "</table>";
?>

#2


0  

this mightbe helpful :

这可能会有所帮助:

CSS Page Breaks

CSS分页符

@media all {
    .page-break { display: none; }
}

@media print {
    .page-break { display: block; page-break-before: always; }
}

Usage

<h1>Page Title</h1>
<!-- content block -->
<!-- content block -->
<div class="page-break"></div>
<!-- content block -->
<!-- content block -->
<div class="page-break"></div>
<!-- content block -->
<!-- content -->

#1


0  

Use page-break-before: always CSS in your table start tag, i.e.

使用page-break-before:表格中的CSS始终开始标记,即

echo '<table style="page-break-before: always">';

Sidenote: MDN suggests that it should be replaced by break-before ( see reference link ), but I DO NOT suggest it, as there is nearly no browser supporting this new CSS3 property.

旁注:MDN建议它应该由break-before替换(参见参考链接),但我不建议,因为几乎没有浏览器支持这个新的CSS3属性。

p.s. I believe the first line should be echo "<table>"; , right?

附:我相信第一行应该是echo“

”; , 对?

Reference : page-break-brefore on MDN

参考:MDN上的分页符

Example:

<?php
echo '<table style="page-break-before: always">';
while($row= mysql_fetch_array($result)){ // Do NOT use mysql_* functions! Use MySQLi / PDO instead
  echo '<tr style="margin-top: 20px;">';
  echo "  <td>$row[data1]</td>";
  echo "  <td>$row[data2]</td>";
  echo "</tr>";
}
echo "</table>";
?>

#2


0  

this mightbe helpful :

这可能会有所帮助:

CSS Page Breaks

CSS分页符

@media all {
    .page-break { display: none; }
}

@media print {
    .page-break { display: block; page-break-before: always; }
}

Usage

<h1>Page Title</h1>
<!-- content block -->
<!-- content block -->
<div class="page-break"></div>
<!-- content block -->
<!-- content block -->
<div class="page-break"></div>
<!-- content block -->
<!-- content -->