php - 如何在dompdf中创建多个页面

标签 php mysql dompdf

我创建了一个从数据库 mysql 获取数据的 dompdf。但我的问题是,如果每个用户的数据将超过 19 个事务,我将如何迭代页面?

<?php
define( 'WP_USE_THEMES', false );
define( 'COOKIE_DOMAIN', false );
define( 'DISABLE_WP_CRON', true );
require('wp-load.php'); 

global $current_user;
get_currentuserinfo();

$d = $current_user->user_login;

// include autoloader
require_once 'dompdf/autoload.inc.php';

// reference the Dompdf namespace
use Dompdf\Dompdf;

// instantiate and use the dompdf class
$dompdf = new Dompdf();

$html = '<html><body>'.
        '<p>Date | Details </p>';

$ff = $wpdb->get_results( "SELECT * FROM table WHERE dd = '$d' ORDER by tdate");
    foreach ( $ff as $jj ) {
     $html = '<p>'.$jj->tdate.' | '.$jj->details.'</p>';
    }

$html .= ''</body></html>';

$dompdf->loadHtml($html);

// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');

// Render the HTML as PDF
$dompdf->render();

// Output the generated PDF to Browser
//$dompdf->stream();

// Output the generated PDF (1 = download and 0 = preview)
$dompdf->stream("codex",array("Attachment"=>0));

目前它仅适用于 1 页,但我的问题是当每个用户的数据超过 19 到更高的事务时,它会破坏页面。我想设置每页 19 个事务。

BTW 示例输出如下所示:

Outout

这里有人能帮帮我吗?

谢谢。

最佳答案

试试这个

$start = '<html><body>';
$body  = '<p>Date | Details </p>';
$ff = $wpdb->get_results( "SELECT * FROM table WHERE dd = '$d' ORDER by tdate");
    foreach ( $ff as $jj ) {
     $body .= '<p>'.$jj->tdate.' | '.$jj->details.'</p>';
    }
$end= '</body></html>';
$dompdf->loadHtml($start.$body.$body.$end);

在您的代码中实现此代码。

关于php - 如何在dompdf中创建多个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41477100/

相关文章:

php - 搜索功能: Error

PHP JPEG 裁剪 : Loss of quality?

mysql - mysql中整列的条目相乘

php - 将内联 css 与 DomPDF 和 Laravel 一起使用

laravel - 将变量从 DOMPDF Controller 传递到 View

css - DOMPDF - 如何将 PDF 呈现为完全没有边距?

php - 我可以在使用 Datamapper/Codeigniter 提交事务后回滚事务吗?

php - 在codeigniter中将excel数据导入数据库

mysql - 查询以查找表的行数

php - 在 PHP 中保存多个 MySQL 数据库连接的解决方案是什么