我有以下PHP文件course.php,我想用dompdf来呈现文件。但是,当我尝试加载外部文件时,它会告诉我已加载的标题。
我已经尝试了一些在线教程但是当我添加内联php时,pdf无法正确呈现。
有没有可能添加外部php文件?
<?php
include config.php
$course_id= JRequest::getInt('cid');
$dbname = "i2894069_jos2";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT en . * , e.full_name, e.level , c.base_level, s.station
FROM enrolled_students AS en
JOIN employees AS e ON en.student = e.user_id
JOIN stations AS s ON e.station = s.id
JOIN courses_instructed AS ci ON en.pid = ci.ci_id
JOIN courses as c on ci.ci_course = c.id
WHERE en.pid =$course_id
ORDER BY e.last_name";
$result = $conn->query($sql);
?>
<style>
.table-fixed thead {
width: 97%;
}
.table-fixed tbody {
height: 230px;
overflow-y: auto;
width: 100%;
}
.table-fixed thead, .table-fixed tbody, .table-fixed tr, .table-fixed td, .table-fixed th {
display: block;
}
.table-fixed tbody td, .table-fixed thead > tr> th {
float: left;
border-bottom-width: 0;
}
</style>
<div class="row">
<div class="panel panel-default">
<div class="panel-heading">
<h4>
Fixed Header Scrolling Table
</h4>
</div>
<table class="table table-fixed">
<thead>
<tr>
<th class="col-xs-4">Student</th><th class="col-xs-4">Station</th><th class="col-xs-4">Level</th>
</tr>
</thead>
<tbody>
<?php while($row = $result->fetch_assoc()) {
if($row['level'] == 11){
$level = 'Ambulette';
}elseif($row['level'] == 2){
$level = 'Dispatcher';
}elseif($row['level'] == 3){
$level = 'EMT';
}elseif($row['level'] == 4){
$level = 'AEMT';
}elseif($row['level'] == 5){
$level = 'Paramedic';
}elseif($row['level'] == 6){
$level = 'IT';
}elseif($row['level'] == 7){
$level = 'RN / Medic';
}
else{$level = '';}
$base_level = $row['base_level'];
$elevel = $row['level'];
if($elevel < $base_level){
$style = 'class="table-warning"';
}else{
$style = '';
}
?>
<tr>
<td class="col-xs-4"><?php echo $row['full_name'] ?></td><td class="col-xs-4"><?php echo $row['station'] ?></td><td class="col-xs-4"><?php echo $level ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
答案 0 :(得分:1)
如果我理解正确的话......你要找的是这样的:
<?php
ob_start();
require 'yourtemplate.php'; // the one you posted in your question
$html = ob_get_clean();
现在您的HTML位于变量中,如果需要,可以使用DOMPDF进行渲染。