我创建了一个从数据库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样本输出如下所示:
这里有人可以帮助我吗?
感谢。
答案 0 :(得分:0)
试试这个
$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);
在您的代码中实现此代码。