来自数据库的数据未显示在tcpdf

时间:2019-11-26 19:06:57

标签: php codeigniter tcpdf

我在使用TCPDF显示数据库中的数据时遇到了一些问题。我有PHP的代码,效果很好。因此,我想将此代码包含在tcpdf中以显示数据库中的数据。我尝试将代码添加到EOF中,但无法正常工作。这是我放入eof之后的代码:

$html = <<<EOF
$url = current_url();
 $str = substr(strrchr($url, '/'), 1);
$student_id= $str;
$corectura = $this->db->get_where('disertatie_corectura',array('student_id'=>$student_id))->result_array();
?>
<style type="text/css">
.tg  {border-collapse:collapse;border-spacing:0;margin:0px auto;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .style2{border-color:inherit;text-align:center;vertical-align:middle}
.tg .style3{border-color:inherit;text-align:left;vertical-align:top}
@media screen and (max-width: 767px) {.tg {width: auto !important;}.tg col {width: auto !important;}.tg-wrap {overflow-x: auto;-webkit-overflow-scrolling: touch;margin: auto 0px;}}</style>
<div class="tg-wrap"><table class="tg">
  <tr>
    <th class="style">Nr crt</th>
    <th class="style">Data si ora corecturi</th>
    <th class="style1">Corectura</th>
    <th class="style1">Anul universitar</th>
  </tr>
  <?php
  $count = 1;
      $sections = $this->db->get_where('disertatie_corectura' , array(
          'student_id' => $student_id
      ))->result_array();
      foreach ($sections as $row):
  ?>
  <tr align='center'>
    <td class="style"><?php echo $count++;?></td>
    <td class="style"><?php echo date("d.m.Y H:i:s" , $row['timestamp']);?></td>
    <td class="style1" align='justify'><?php echo $row['corectura'];?></td>
    <td class="style1"><?php echo $row['year'];?></td>
  </tr>
   <?php endforeach;?>
</table></div>
EOF;
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');

0 个答案:

没有答案