1
任何人都可以幫助我使用MPDF生成pdf以用於以下代碼。從php生成的HTML表中生成PDF
<table width="360" height="161" border="1" class="tablestyle">
<tr>
<td height="36" colspan="5" bgcolor="#ECE9D8"><div align="center" class="style6">ACADEMIC PERFORMANCE - <br />
UNIT TEST</div></td>
</tr>
<tr>
<td width="89"><div align="center" class="style3 style8">SUBJECTS</div></td>
<td width="73"><div align="center" class="style9">No. Of Tests</div></td>
<td width="82"><div align="center" class="style9">Mark Obtained</div></td>
<td width="82"><div align="center" class="style9">Full Mark</div></td>
<td width="88"><div align="center" class="style9">12.5% of <br />Mark Scored</div></td>
</tr>
<?php do { ?>
<tr>
<td><span class="style7"> <?php echo $row_dep['Subject'];?></span></td>
<td><div align="center"><?php echo $row_dep['times'];?></div></td>
<td><div align="center"><?php echo $row_dep['score'];?></div></td>
<td><div align="center"><?php echo $row_dep['fm'];?></div></td>
<td><div align="center"><?php echo number_format($row_dep['score']/$row_dep['fm']*12.5,2); ?></div></td>
</tr>
<?php } while ($row_dep = mysql_fetch_assoc($dep)); ?>
<tr>
<td bgcolor="#ECE9D8"><div align="center"><strong>Total</strong></div></td>
<td bgcolor="#ECE9D8"><div align="center"><?php echo $row_exe['ex'];?></div></td>
<td bgcolor="#ECE9D8"><div align="center"><?php echo $row_unit['utotal'];?></div></td>
<td bgcolor="#ECE9D8"><div align="center"><?php echo $row_unfm['ufm'];?></div></td>
<td bgcolor="#ECE9D8"><div align="center"><strong><?php echo number_format($row_unit['utotal']/$row_unfm['ufm']*12.5,2); ?></strong></div></td>
</tr>
<tr>
<td colspan="2"><div align="right"><strong>Grade:</strong></div></td>
<td><div align="center"><strong><?php
$div=$row_unit['utotal']/$row_unfm['ufm']*100;
if ($div>=90)
{
echo "A1";
}
elseif($div>=80)
{
echo "A2";
}
elseif($div>=70)
{
echo "B1";
}
elseif($div>=60)
{
echo "B2";
}
elseif($div>=50)
{
echo "C1";
}
elseif($div>=40)
{
echo "C2";
}
elseif($div>=33)
{
echo "D";
}
elseif($div>=21)
{
echo "<font color=red>E1</font>";
}
else
{
echo "<font color=red>E2</font>";
}
?></strong></div></td>
<td><strong><div align="center">Percentage</strong></div></td>
<td><strong><div align="center">
<?php
echo number_format($row_unit['utotal']/$row_unfm['ufm']*100,2);
?>%
</strong></div></td>
</tr>
</table>
我希望把上表內$html
,我一直在試圖與在MPDF手冊中給出了一些樣品,但無法弄清楚如何輸出。例如,對於在$HMTL
打印<?php echo $row_dep['Name_of_Student'];?>
我知道,我可以使用'.$row_dep['Name_of_Student'].'
但我在這裏<?php do { ?>
和<?php } while ($row_dep = mysql_fetch_assoc($dep)); ?>
之間,我不知道,無法產生所需的輸出,當談到生成行。
你看着輸出緩衝(見'ob_start()')? – cimmanon
@cimmanon不,我不知道如何使用'ob_start()'。我是新來的PHP。這可以在不使用ob_start()函數的情況下完成嗎?由於MPDF不允許在'$ html'中使用'<?php echo',我想知道如何使用MPDF在PDF中輸出上述腳本。 –
@cimmanon'ob_start()'不適用於上述代碼。 –