首页 > 解决方案 > 如何在 tcpdf 中创建垂直侧标题表

问题描述

当我使用这种方法时,表格的标题是水平的,而不是垂直的。

  $link= mysqli_connect($host, $user, $pass, $db);


   if (isset($_GET['eid']))
   {
  $eid=$_GET['eid'];
   }



  $output = '';  
  $count=0;
  $sql = "SELECT * FROM event_record where eventID='{$eid}' ";  
  $result = mysqli_query($link, $sql);  
  while($row = mysqli_fetch_array($result))  
  {       
      $count++;
  $output .= "<tr>  
                      <td>$count</td>
                      <td>{$row['studentID']}</td>  
                      <td>{$row['studentName']}</td>  
                      <td>{$row['contact']}</td>  
                      <td>{$row['program']}</td>
                      <td>{$row['booking_date']}</td>
                      <td>{$row['booking_type']}</td>  
                 </tr>  
                      ";  

  }  

  return $output;  

我想要 pdf 的结果是,表格标题在垂直和左侧,而不是水平。

 <table class="table table-bordered">  
                      <tr>  
                           <th width="3%">No.</th>  
                           <th width="10%">Student ID</th> 
                           <th width="10%">Student Name</th>  
                           <th width="10%">Contact</th>  
                           <th width="5%">Program</th>  
                           <th width="8%">Booking Date</th>
                           <th width="10%">Booking Type</th>  
                      </tr>  
                 <?php  
                 echo fetch_data();  
                 ?>  
                 </table>  

下面的代码是合并值和表格标题

  <table border="1" cellspacing="0" cellpadding="3">  
       <tr>  
            <th width="5%">No.</th>  
            <th width="15%">Student ID</th> 
            <th width="20%">Student Name</th>  
            <th width="15%">Contact</th>  
            <th width="10%">Program</th>  
            <th width="15%">Booking Date</th>
            <th width="15%">Booking Type</th>  
       </tr>  
  ';  
  $content .= fetch_data();  
  $content .= '</table>';  
  $obj_pdf->writeHTML($content);  
  $obj_pdf->Output('file.pdf', 'I');

我需要这样的结果,

标签: phptcpdf

解决方案


推荐阅读