在双引号或单引号中打印 HTML 和 PHP 代码
Print the HTML and PHP Code in Double or single quotation marks
我正在显示 HTML Table,它从 PHP 中的数据库中获取数据,并将其导出到 PDF 页面中...一切都很好,但是当下载 PDF 文件时,除了来自 Mysql 的值在 table 中显示 php 代码,问题是引号,所以如何用引号写代码,它在 [= 中显示值31=] 除了 php 代码?
点击它时
<a href="file.php" class="export-pdf" data-filename="PDFFILE"><button type="button" class="btn btn-success">PDF FORMAT</button></a>
导出 Table PDF 代码 "FILE.PHP"
<?php require_once 'components/app.php'; ?>
<?php
include('mpdf/mpdf.php');
$mpdf=new mPDF();
$mpdf->WriteHTML("
<table id='fixed_table' class='table table-bordered table-hover'>
<thead>
<tr>
<th>District</th>
<th>Union Council</th>
<th>Village</th>
<th>Recreational</th>
<th>Awareness Raising</th>
<th>Training</th>
<th>Social Mobilization</th>
<th>Total Activities</th>
</tr>
</thead>
<tbody>
<tr>
<td style='color:red;'><b><?php echo getTotalDistrictUnique();?></b></td>
<td style='color:red;'><b><?php echo getTotalUnionCouncilUnique();?></b></td>
<td style='color:red;'><b><?php echo getTotalVillages(); ?></b></td>
<td style='color:red;'><b><?php echo getTotalRecreational();?></b></td>
<td style='color:red;'><b><?php echo getTotalAwareness();?></b></td>
<td style='color:red;'><b><?php echo getTotalTraining();?></b></td>
<td style='color:red;'><b><?php echo getTotalSocial();?></b></td>
<td style='color:red;'><b><?php echo getTotalRecreational() + getTotalAwareness() + getTotalTraining() + getTotalSocial(); ?></td>
</tr>
<?php
include('connection.php');
$query ='select * from general';
$run =mysqli_query($con,$query);
while ($row=mysqli_fetch_array($run)) {
$id=$row[0];
$createdate=$row[1];
$createday=$row[2];
$partnername=$row[3];
$district=$row[4];
$unioncouncil=$row[5];
$village=$row[6];
$vannumber=$row[7];
$facilitator=$row[8];
$beneficiarytype=$row[9];
$rmultimedia=$row[10];
$rgame=$row[11];
$rsprort=$row[12];
$rart=$row[13];
$rgroupreading=$row[14];
$rother=$row[15];
$alandminer=$row[16];
$apersonalsafety=$row[17];
$abirthregister=$row[18];
$aother=$row[19];
$tstickstone=$row[20];
$tohthers=$row[21];
$sbirthregister=$row[22];
$sother=$row[23];
$formnumber=$row[24];
$submitdatatime=$row[25];
?>
<tr>
<td><?php echo $district?></td>
<td><?php echo $unioncouncil?></td>
<td><?php echo $village?></td>
<td>
<?php
if($rmultimedia=='true')
{
$rmultimedia_value = 1;
}
else{
$rmultimedia_value = 0;
}
if($rgame=='true')
{
$rgame_value = 1;
}
else{
$rgame_value = 0;
}
if($rsprort=='true')
{
$rsprort_value = 1;
}
else{
$rsprort_value = 0;
}
if($rart=='true')
{
$rart_value = 1;
}
else{
$rart_value = 0;
}
if($rgroupreading=='true')
{
$rgroupreading_value = 1;
}
else{
$rgroupreading_value = 0;
}
if($rother=='true')
{
$rother_value = 1;
}
else{
$rother_value = 0;
}
$recreational_sum = $rmultimedia_value + $rgame_value + $rsprort_value + $rart_value + $rgroupreading_value + $rother_value;
echo $recreational_sum;?></td>
<td>
<?php
if($alandminer=='true')
{
$alandminer_value = 1;
}
else{
$alandminer_value = 0;
}
if($apersonalsafety=='true')
{
$apersonalsafety_value = 1;
}
else{
$apersonalsafety_value = 0;
}
if($abirthregister=='true')
{
$abirthregister_value = 1;
}
else{
$abirthregister_value = 0;
}
if($aother=='true')
{
$aother_value = 1;
}
else{
$aother_value = 0;
}
$awareness_raising_sum = $alandminer_value + $apersonalsafety_value + $abirthregister_value + $aother_value;
echo $awareness_raising_sum;?>
</td>
<td>
<?php
if($tstickstone=='true')
{
$tstickstone_value = 1;
}
else{
$tstickstone_value = 0;
}
if($tohthers=='true')
{
$tohthers_value = 1;
}
else{
$tohthers_value = 0;
}
$training_sum = $tstickstone_value + $tohthers_value;
echo $training_sum;?>
</td>
<td>
<?php
if($sbirthregister=='true')
{
$sbirthregister_value = 1;
}
else{
$sbirthregister_value = 0;
}
if($sother=='true')
{
$sother_value = 1;
}
else{
$sother_value = 0;
}
$social_mobilization_sum = $sbirthregister_value + $sother_value;
echo $social_mobilization_sum;?>
</td>
<td style='color:red;'><?php echo $recreational_sum + $awareness_raising_sum + $training_sum + $social_mobilization_sum;?></td>
</tr>
<?php } ?>
</tbody>
</table>
");
$mpdf->Output(); exit;
?>
写下这些行:
<td style='color:red;'><b><?php echo getTotalDistrictUnique();?></b></td>
像这样:
<td style='color:red;'><b>".getTotalDistrictUnique()."</b></td>
您的代码 strucktur 是这样构建的:
<?php
...
<?php // this is wrong, the opening PHP tag is still alive
... getTotalDistrictUnique()...
?>
?>
您与 php
的连接不正确。
请检查下面的代码,如果有任何问题请在评论框中告诉我。
<?php
require_once 'components/app.php';
include('mpdf/mpdf.php');
$mpdf=new mPDF();
$html = "";
$html .= "
<table id='fixed_table' class='table table-bordered table-hover'>
<thead>
<tr>
<th>District</th>
<th>Union Council</th>
<th>Village</th>
<th>Recreational</th>
<th>Awareness Raising</th>
<th>Training</th>
<th>Social Mobilization</th>
<th>Total Activities</th>
</tr>
</thead>
<tbody>
<tr>
<td style='color:red;'><b>".getTotalDistrictUnique()."</b></td>
<td style='color:red;'><b>".getTotalUnionCouncilUnique()."</b></td>
<td style='color:red;'><b>".getTotalVillages()."</b></td>
<td style='color:red;'><b>".getTotalRecreational()."</b></td>
<td style='color:red;'><b>".getTotalAwareness()."</b></td>
<td style='color:red;'><b>".getTotalTraining()."</b></td>
<td style='color:red;'><b>".getTotalSocial()."</b></td>
<td style='color:red;'><b>".(getTotalRecreational() + getTotalAwareness() + getTotalTraining() + getTotalSocial())."</td>
</tr>";
include('connection.php');
$query ='select * from general';
$run =mysqli_query($con,$query);
while ($row=mysqli_fetch_array($run)) {
$id=$row[0];
$createdate=$row[1];
$createday=$row[2];
$partnername=$row[3];
$district=$row[4];
$unioncouncil=$row[5];
$village=$row[6];
$vannumber=$row[7];
$facilitator=$row[8];
$beneficiarytype=$row[9];
$rmultimedia=$row[10];
$rgame=$row[11];
$rsprort=$row[12];
$rart=$row[13];
$rgroupreading=$row[14];
$rother=$row[15];
$alandminer=$row[16];
$apersonalsafety=$row[17];
$abirthregister=$row[18];
$aother=$row[19];
$tstickstone=$row[20];
$tohthers=$row[21];
$sbirthregister=$row[22];
$sother=$row[23];
$formnumber=$row[24];
$submitdatatime=$row[25];
$html .= '<tr>';
$html .= '<td>'.$district;
$html .= '</td>';
$html .= '<td>'.$unioncouncil;
$html .= '</td>';
$html .= '<td>'.$village;
$html .= '</td>';
if($rmultimedia=='true')
{
$rmultimedia_value = 1;
}
else{
$rmultimedia_value = 0;
}
if($rgame=='true')
{
$rgame_value = 1;
}
else{
$rgame_value = 0;
}
if($rsprort=='true')
{
$rsprort_value = 1;
}
else{
$rsprort_value = 0;
}
if($rart=='true')
{
$rart_value = 1;
}
else{
$rart_value = 0;
}
if($rgroupreading=='true')
{
$rgroupreading_value = 1;
}
else{
$rgroupreading_value = 0;
}
if($rother=='true')
{
$rother_value = 1;
}
else{
$rother_value = 0;
}
$recreational_sum = $rmultimedia_value + $rgame_value + $rsprort_value + $rart_value + $rgroupreading_value + $rother_value;
$html .= '<td>'.$recreational_sum;
$html .= '</td>';
if($alandminer=='true')
{
$alandminer_value = 1;
}
else{
$alandminer_value = 0;
}
if($apersonalsafety=='true')
{
$apersonalsafety_value = 1;
}
else{
$apersonalsafety_value = 0;
}
if($abirthregister=='true')
{
$abirthregister_value = 1;
}
else{
$abirthregister_value = 0;
}
if($aother=='true')
{
$aother_value = 1;
}
else{
$aother_value = 0;
}
$awareness_raising_sum = $alandminer_value + $apersonalsafety_value + $abirthregister_value + $aother_value;
$html .= '<td>'.$awareness_raising_sum;
$html .= '</td>';
if($tstickstone=='true')
{
$tstickstone_value = 1;
}
else{
$tstickstone_value = 0;
}
if($tohthers=='true')
{
$tohthers_value = 1;
}
else{
$tohthers_value = 0;
}
$training_sum = $tstickstone_value + $tohthers_value;
$html .= '<td>'.$training_sum;
$html .= '</td>';
if($sbirthregister=='true')
{
$sbirthregister_value = 1;
}
else{
$sbirthregister_value = 0;
}
if($sother=='true')
{
$sother_value = 1;
}
else{
$sother_value = 0;
}
$social_mobilization_sum = $sbirthregister_value + $sother_value;
$html .= '<td>'.$social_mobilization_sum;
$html .= '</td>';
$html .= '<td style="color:red;">'.($recreational_sum + $awareness_raising_sum + $training_sum + $social_mobilization_sum);
$html .= '</td>';
$html .= '</tr>';
$html .= '</tbody>';
$html .= '</table>';
$mpdf->WriteHTML($html);
$mpdf->Output(); exit;
?>
你的代码很乱。字符串中的 PHP 代码只是一个字符串,不再是代码。您应该正确编写代码。
<?php
require_once 'components/app.php';
include('connection.php');
include('mpdf/mpdf.php');
$content = '
<table id="fixed_table" class="table table-bordered table-hover">
<thead>
<tr>
<th>District</th>
<th>Union Council</th>
<th>Village</th>
<th>Recreational</th>
<th>Awareness Raising</th>
<th>Training</th>
<th>Social Mobilization</th>
<th>Total Activities</th>
</tr>
</thead>
<tbody>
<tr>
<td style="color:red;"><b>' . getTotalDistrictUnique() . '</b></td>
<td style="color:red;"><b>' . getTotalUnionCouncilUnique() . '</b></td>
<td style="color:red;"><b>' . getTotalVillages() . '</b></td>
<td style="color:red;"><b>' . getTotalRecreational() . '</b></td>
<td style="color:red;"><b>' . getTotalAwareness() . '</b></td>
<td style="color:red;"><b>' . getTotalTraining() . '</b></td>
<td style="color:red;"><b>' . getTotalSocial() . '</b></td>
<td style="color:red;"><b>' . (getTotalRecreational() + getTotalAwareness() + getTotalTraining() + getTotalSocial()) . '</td>
</tr>
';
$query ='select * from general';
$run =mysqli_query($con,$query);
while ($row=mysqli_fetch_array($run)) {
$id=$row[0];
$createdate=$row[1];
$createday=$row[2];
$partnername=$row[3];
$district=$row[4];
$unioncouncil=$row[5];
$village=$row[6];
$vannumber=$row[7];
$facilitator=$row[8];
$beneficiarytype=$row[9];
$rmultimedia=$row[10];
$rgame=$row[11];
$rsprort=$row[12];
$rart=$row[13];
$rgroupreading=$row[14];
$rother=$row[15];
$alandminer=$row[16];
$apersonalsafety=$row[17];
$abirthregister=$row[18];
$aother=$row[19];
$tstickstone=$row[20];
$tohthers=$row[21];
$sbirthregister=$row[22];
$sother=$row[23];
$formnumber=$row[24];
$submitdatatime=$row[25];
$rmultimedia_value = $rmultimedia == 'true' ? 1 : 0;
$rgame_value = $rgame == 'true' ? 1 : 0;
$rsprort_value = $rsprort == 'true' ? 1 : 0;
$rart_value = $rart == 'true' ? 1 : 0;
$rgroupreading_value = $rgroupreading == 'true' ? 1 : 0;
$rother_value = $rother == 'true' ? 1 : 0;
$recreational_sum = $rmultimedia_value + $rgame_value + $rsprort_value + $rart_value + $rgroupreading_value + $rother_value;
$alandminer_value = $alandminer == 'true' ? 1 : 0;
$apersonalsafety_value = $apersonalsafety == 'true' ? 1 : 0;
$abirthregister_value = $abirthregister == 'true' ? 1 : 0;
$aother_value = $aother == 'true' ? 1 : 0;
$awareness_raising_sum = $alandminer_value + $apersonalsafety_value + $abirthregister_value + $aother_value;
$tstickstone_value = $tstickstone == 'true' ? 1 : 0;
$tohthers_value = $tohthers == 'true' ? 1 : 0;
$training_sum = $tstickstone_value + $tohthers_value;
$sbirthregister_value = $sbirthregister == 'true' ? 1 : 0;
$sother_value = $sother == 'true'? 1 : 0;
$social_mobilization_sum = $sbirthregister_value + $sother_value;
$content .= '
<tr>
<td>' . $district . '</td>
<td>' . $unioncouncil . '</td>
<td>' . $village . '</td>
<td>' . $recreational_sum . '</td>
<td>' . $awareness_raising_sum . '</td>
<td>' . $training_sum . '</td>
<td>' . $social_mobilization_sum . '</td>
<td style="color:red;">' . ($recreational_sum + $awareness_raising_sum + $training_sum + $social_mobilization_sum) . '</td>
</tr>';
}
$content .= '</tbody></table>';
$mpdf=new mPDF();
$mpdf->WriteHTML($content);
$mpdf->Output();
exit;
?>
我正在显示 HTML Table,它从 PHP 中的数据库中获取数据,并将其导出到 PDF 页面中...一切都很好,但是当下载 PDF 文件时,除了来自 Mysql 的值在 table 中显示 php 代码,问题是引号,所以如何用引号写代码,它在 [= 中显示值31=] 除了 php 代码?
点击它时
<a href="file.php" class="export-pdf" data-filename="PDFFILE"><button type="button" class="btn btn-success">PDF FORMAT</button></a>
导出 Table PDF 代码 "FILE.PHP"
<?php require_once 'components/app.php'; ?>
<?php
include('mpdf/mpdf.php');
$mpdf=new mPDF();
$mpdf->WriteHTML("
<table id='fixed_table' class='table table-bordered table-hover'>
<thead>
<tr>
<th>District</th>
<th>Union Council</th>
<th>Village</th>
<th>Recreational</th>
<th>Awareness Raising</th>
<th>Training</th>
<th>Social Mobilization</th>
<th>Total Activities</th>
</tr>
</thead>
<tbody>
<tr>
<td style='color:red;'><b><?php echo getTotalDistrictUnique();?></b></td>
<td style='color:red;'><b><?php echo getTotalUnionCouncilUnique();?></b></td>
<td style='color:red;'><b><?php echo getTotalVillages(); ?></b></td>
<td style='color:red;'><b><?php echo getTotalRecreational();?></b></td>
<td style='color:red;'><b><?php echo getTotalAwareness();?></b></td>
<td style='color:red;'><b><?php echo getTotalTraining();?></b></td>
<td style='color:red;'><b><?php echo getTotalSocial();?></b></td>
<td style='color:red;'><b><?php echo getTotalRecreational() + getTotalAwareness() + getTotalTraining() + getTotalSocial(); ?></td>
</tr>
<?php
include('connection.php');
$query ='select * from general';
$run =mysqli_query($con,$query);
while ($row=mysqli_fetch_array($run)) {
$id=$row[0];
$createdate=$row[1];
$createday=$row[2];
$partnername=$row[3];
$district=$row[4];
$unioncouncil=$row[5];
$village=$row[6];
$vannumber=$row[7];
$facilitator=$row[8];
$beneficiarytype=$row[9];
$rmultimedia=$row[10];
$rgame=$row[11];
$rsprort=$row[12];
$rart=$row[13];
$rgroupreading=$row[14];
$rother=$row[15];
$alandminer=$row[16];
$apersonalsafety=$row[17];
$abirthregister=$row[18];
$aother=$row[19];
$tstickstone=$row[20];
$tohthers=$row[21];
$sbirthregister=$row[22];
$sother=$row[23];
$formnumber=$row[24];
$submitdatatime=$row[25];
?>
<tr>
<td><?php echo $district?></td>
<td><?php echo $unioncouncil?></td>
<td><?php echo $village?></td>
<td>
<?php
if($rmultimedia=='true')
{
$rmultimedia_value = 1;
}
else{
$rmultimedia_value = 0;
}
if($rgame=='true')
{
$rgame_value = 1;
}
else{
$rgame_value = 0;
}
if($rsprort=='true')
{
$rsprort_value = 1;
}
else{
$rsprort_value = 0;
}
if($rart=='true')
{
$rart_value = 1;
}
else{
$rart_value = 0;
}
if($rgroupreading=='true')
{
$rgroupreading_value = 1;
}
else{
$rgroupreading_value = 0;
}
if($rother=='true')
{
$rother_value = 1;
}
else{
$rother_value = 0;
}
$recreational_sum = $rmultimedia_value + $rgame_value + $rsprort_value + $rart_value + $rgroupreading_value + $rother_value;
echo $recreational_sum;?></td>
<td>
<?php
if($alandminer=='true')
{
$alandminer_value = 1;
}
else{
$alandminer_value = 0;
}
if($apersonalsafety=='true')
{
$apersonalsafety_value = 1;
}
else{
$apersonalsafety_value = 0;
}
if($abirthregister=='true')
{
$abirthregister_value = 1;
}
else{
$abirthregister_value = 0;
}
if($aother=='true')
{
$aother_value = 1;
}
else{
$aother_value = 0;
}
$awareness_raising_sum = $alandminer_value + $apersonalsafety_value + $abirthregister_value + $aother_value;
echo $awareness_raising_sum;?>
</td>
<td>
<?php
if($tstickstone=='true')
{
$tstickstone_value = 1;
}
else{
$tstickstone_value = 0;
}
if($tohthers=='true')
{
$tohthers_value = 1;
}
else{
$tohthers_value = 0;
}
$training_sum = $tstickstone_value + $tohthers_value;
echo $training_sum;?>
</td>
<td>
<?php
if($sbirthregister=='true')
{
$sbirthregister_value = 1;
}
else{
$sbirthregister_value = 0;
}
if($sother=='true')
{
$sother_value = 1;
}
else{
$sother_value = 0;
}
$social_mobilization_sum = $sbirthregister_value + $sother_value;
echo $social_mobilization_sum;?>
</td>
<td style='color:red;'><?php echo $recreational_sum + $awareness_raising_sum + $training_sum + $social_mobilization_sum;?></td>
</tr>
<?php } ?>
</tbody>
</table>
");
$mpdf->Output(); exit;
?>
写下这些行:
<td style='color:red;'><b><?php echo getTotalDistrictUnique();?></b></td>
像这样:
<td style='color:red;'><b>".getTotalDistrictUnique()."</b></td>
您的代码 strucktur 是这样构建的:
<?php
...
<?php // this is wrong, the opening PHP tag is still alive
... getTotalDistrictUnique()...
?>
?>
您与 php
的连接不正确。
请检查下面的代码,如果有任何问题请在评论框中告诉我。
<?php
require_once 'components/app.php';
include('mpdf/mpdf.php');
$mpdf=new mPDF();
$html = "";
$html .= "
<table id='fixed_table' class='table table-bordered table-hover'>
<thead>
<tr>
<th>District</th>
<th>Union Council</th>
<th>Village</th>
<th>Recreational</th>
<th>Awareness Raising</th>
<th>Training</th>
<th>Social Mobilization</th>
<th>Total Activities</th>
</tr>
</thead>
<tbody>
<tr>
<td style='color:red;'><b>".getTotalDistrictUnique()."</b></td>
<td style='color:red;'><b>".getTotalUnionCouncilUnique()."</b></td>
<td style='color:red;'><b>".getTotalVillages()."</b></td>
<td style='color:red;'><b>".getTotalRecreational()."</b></td>
<td style='color:red;'><b>".getTotalAwareness()."</b></td>
<td style='color:red;'><b>".getTotalTraining()."</b></td>
<td style='color:red;'><b>".getTotalSocial()."</b></td>
<td style='color:red;'><b>".(getTotalRecreational() + getTotalAwareness() + getTotalTraining() + getTotalSocial())."</td>
</tr>";
include('connection.php');
$query ='select * from general';
$run =mysqli_query($con,$query);
while ($row=mysqli_fetch_array($run)) {
$id=$row[0];
$createdate=$row[1];
$createday=$row[2];
$partnername=$row[3];
$district=$row[4];
$unioncouncil=$row[5];
$village=$row[6];
$vannumber=$row[7];
$facilitator=$row[8];
$beneficiarytype=$row[9];
$rmultimedia=$row[10];
$rgame=$row[11];
$rsprort=$row[12];
$rart=$row[13];
$rgroupreading=$row[14];
$rother=$row[15];
$alandminer=$row[16];
$apersonalsafety=$row[17];
$abirthregister=$row[18];
$aother=$row[19];
$tstickstone=$row[20];
$tohthers=$row[21];
$sbirthregister=$row[22];
$sother=$row[23];
$formnumber=$row[24];
$submitdatatime=$row[25];
$html .= '<tr>';
$html .= '<td>'.$district;
$html .= '</td>';
$html .= '<td>'.$unioncouncil;
$html .= '</td>';
$html .= '<td>'.$village;
$html .= '</td>';
if($rmultimedia=='true')
{
$rmultimedia_value = 1;
}
else{
$rmultimedia_value = 0;
}
if($rgame=='true')
{
$rgame_value = 1;
}
else{
$rgame_value = 0;
}
if($rsprort=='true')
{
$rsprort_value = 1;
}
else{
$rsprort_value = 0;
}
if($rart=='true')
{
$rart_value = 1;
}
else{
$rart_value = 0;
}
if($rgroupreading=='true')
{
$rgroupreading_value = 1;
}
else{
$rgroupreading_value = 0;
}
if($rother=='true')
{
$rother_value = 1;
}
else{
$rother_value = 0;
}
$recreational_sum = $rmultimedia_value + $rgame_value + $rsprort_value + $rart_value + $rgroupreading_value + $rother_value;
$html .= '<td>'.$recreational_sum;
$html .= '</td>';
if($alandminer=='true')
{
$alandminer_value = 1;
}
else{
$alandminer_value = 0;
}
if($apersonalsafety=='true')
{
$apersonalsafety_value = 1;
}
else{
$apersonalsafety_value = 0;
}
if($abirthregister=='true')
{
$abirthregister_value = 1;
}
else{
$abirthregister_value = 0;
}
if($aother=='true')
{
$aother_value = 1;
}
else{
$aother_value = 0;
}
$awareness_raising_sum = $alandminer_value + $apersonalsafety_value + $abirthregister_value + $aother_value;
$html .= '<td>'.$awareness_raising_sum;
$html .= '</td>';
if($tstickstone=='true')
{
$tstickstone_value = 1;
}
else{
$tstickstone_value = 0;
}
if($tohthers=='true')
{
$tohthers_value = 1;
}
else{
$tohthers_value = 0;
}
$training_sum = $tstickstone_value + $tohthers_value;
$html .= '<td>'.$training_sum;
$html .= '</td>';
if($sbirthregister=='true')
{
$sbirthregister_value = 1;
}
else{
$sbirthregister_value = 0;
}
if($sother=='true')
{
$sother_value = 1;
}
else{
$sother_value = 0;
}
$social_mobilization_sum = $sbirthregister_value + $sother_value;
$html .= '<td>'.$social_mobilization_sum;
$html .= '</td>';
$html .= '<td style="color:red;">'.($recreational_sum + $awareness_raising_sum + $training_sum + $social_mobilization_sum);
$html .= '</td>';
$html .= '</tr>';
$html .= '</tbody>';
$html .= '</table>';
$mpdf->WriteHTML($html);
$mpdf->Output(); exit;
?>
你的代码很乱。字符串中的 PHP 代码只是一个字符串,不再是代码。您应该正确编写代码。
<?php
require_once 'components/app.php';
include('connection.php');
include('mpdf/mpdf.php');
$content = '
<table id="fixed_table" class="table table-bordered table-hover">
<thead>
<tr>
<th>District</th>
<th>Union Council</th>
<th>Village</th>
<th>Recreational</th>
<th>Awareness Raising</th>
<th>Training</th>
<th>Social Mobilization</th>
<th>Total Activities</th>
</tr>
</thead>
<tbody>
<tr>
<td style="color:red;"><b>' . getTotalDistrictUnique() . '</b></td>
<td style="color:red;"><b>' . getTotalUnionCouncilUnique() . '</b></td>
<td style="color:red;"><b>' . getTotalVillages() . '</b></td>
<td style="color:red;"><b>' . getTotalRecreational() . '</b></td>
<td style="color:red;"><b>' . getTotalAwareness() . '</b></td>
<td style="color:red;"><b>' . getTotalTraining() . '</b></td>
<td style="color:red;"><b>' . getTotalSocial() . '</b></td>
<td style="color:red;"><b>' . (getTotalRecreational() + getTotalAwareness() + getTotalTraining() + getTotalSocial()) . '</td>
</tr>
';
$query ='select * from general';
$run =mysqli_query($con,$query);
while ($row=mysqli_fetch_array($run)) {
$id=$row[0];
$createdate=$row[1];
$createday=$row[2];
$partnername=$row[3];
$district=$row[4];
$unioncouncil=$row[5];
$village=$row[6];
$vannumber=$row[7];
$facilitator=$row[8];
$beneficiarytype=$row[9];
$rmultimedia=$row[10];
$rgame=$row[11];
$rsprort=$row[12];
$rart=$row[13];
$rgroupreading=$row[14];
$rother=$row[15];
$alandminer=$row[16];
$apersonalsafety=$row[17];
$abirthregister=$row[18];
$aother=$row[19];
$tstickstone=$row[20];
$tohthers=$row[21];
$sbirthregister=$row[22];
$sother=$row[23];
$formnumber=$row[24];
$submitdatatime=$row[25];
$rmultimedia_value = $rmultimedia == 'true' ? 1 : 0;
$rgame_value = $rgame == 'true' ? 1 : 0;
$rsprort_value = $rsprort == 'true' ? 1 : 0;
$rart_value = $rart == 'true' ? 1 : 0;
$rgroupreading_value = $rgroupreading == 'true' ? 1 : 0;
$rother_value = $rother == 'true' ? 1 : 0;
$recreational_sum = $rmultimedia_value + $rgame_value + $rsprort_value + $rart_value + $rgroupreading_value + $rother_value;
$alandminer_value = $alandminer == 'true' ? 1 : 0;
$apersonalsafety_value = $apersonalsafety == 'true' ? 1 : 0;
$abirthregister_value = $abirthregister == 'true' ? 1 : 0;
$aother_value = $aother == 'true' ? 1 : 0;
$awareness_raising_sum = $alandminer_value + $apersonalsafety_value + $abirthregister_value + $aother_value;
$tstickstone_value = $tstickstone == 'true' ? 1 : 0;
$tohthers_value = $tohthers == 'true' ? 1 : 0;
$training_sum = $tstickstone_value + $tohthers_value;
$sbirthregister_value = $sbirthregister == 'true' ? 1 : 0;
$sother_value = $sother == 'true'? 1 : 0;
$social_mobilization_sum = $sbirthregister_value + $sother_value;
$content .= '
<tr>
<td>' . $district . '</td>
<td>' . $unioncouncil . '</td>
<td>' . $village . '</td>
<td>' . $recreational_sum . '</td>
<td>' . $awareness_raising_sum . '</td>
<td>' . $training_sum . '</td>
<td>' . $social_mobilization_sum . '</td>
<td style="color:red;">' . ($recreational_sum + $awareness_raising_sum + $training_sum + $social_mobilization_sum) . '</td>
</tr>';
}
$content .= '</tbody></table>';
$mpdf=new mPDF();
$mpdf->WriteHTML($content);
$mpdf->Output();
exit;
?>