TCPDF仅显示来自DB的第一条记录,而不显示其他记录

时间:2017-03-11 10:15:05

标签: php pdf

我想将视图文件转换为pdf ..查看文件有来自db的记录...但是当它渲染为pdf时,没有数据显示php变量来自哪里.. 任何人都可以提出什么问题:

在“公司”显示其显示空白pdf

之后

这是pdf创建代码:

error_reporting(-1);
                require_once('TCPDF/tcpdf.php');        
                $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
                $pdf->SetCreator(PDF_CREATOR);
                $pdf->setPrintHeader(false);
                $pdf->setPrintFooter(false);
                $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
                $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
                $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
                $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
                if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
                    require_once(dirname(__FILE__).'/lang/eng.php');
                    $pdf->setLanguageArray($l);
                }
                $pdf->setFontSubsetting(true);
                $pdf->SetFont('dejavusans', '', 14, '', true);
                $pdf->AddPage();
                $pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
                $html = $this->load->view('frontend/quotes_detail_po_pdf', $data, TRUE);
                $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
                ob_end_clean();
                $pdf->Output($prorder.".pdf", 'I'); 

查看文件:

<div class="col-xs-12 nopad">
            <div class="col-xs-5 nopad qts">
                <h2>Purchase Request Details</h2>
                <table width="100%" border="0" class="qtable" cellspacing="0" cellpadding="0">
                <tr>
                  <th width="40%">Company</th>
                  <td width="2%">:
                    </th>
                  <td width="585"><?php echo $compdata[0]->name;?></td>
                </tr>
                <tr>
                  <th>Department</th>
                  <td>:</td>
                  <td><?php echo $deprow[0]->department;?></td>
                </tr>
                <tr>
                  <th>Referrence #</th>
                  <td>:</td>
                  <td><?php echo $pritem[0]->pReference;?></td>
                </tr>
                <tr>
                  <th>Request Created</th>
                  <td>:</td>
                  <td><?php if($pritem[0]->pCreated != ""){echo date("F, d Y - h:i A",strtotime($pritem[0]->pCreated));}?></td>
                </tr>
                <tr>
                  <th>Approved By</th>
                  <td>:</td>
                  <td><?php if($pritem[0]->pApproveBy == 0){}else { echo $approve[0]->first_name." ".$approve[0]->last_name;} ?></td>
                </tr>
                <tr>
                  <th>Approved Date</th>
                  <td>:</td>
                  <td><?php if($pritem[0]->pApproveDate != ""){echo date("F, d Y - h:i A",strtotime($pritem[0]->pApproveDate));}?></td>
                </tr>
                <tr>
                  <th>Status</th>
                  <td>:</td>
                  <td><?php if($pritem[0]->pApproved == 0){echo "<strong style='color:#f00'>Pending</strong>";}else { echo "<strong style='color:#109D00;'>Approved</strong>";} ?></td>
                </tr>
              </table>
            </div>
            <div class="col-xs-7 qts">
              <h2>Vendor Details</h2>
              <table width="100%" border="0" class="qtable" cellspacing="0" cellpadding="0">
                <tr>
                  <th width="40%">Vendor Name</th>
                  <td width="2%">:
                    </th>
                  <td width="585"><?php echo $vendorsdata[0]->displayName;?></td>
                </tr>
                <tr>
                  <th>Email Address</th>
                  <td>:</td>
                  <td><?php echo $vendorsdata[0]->cEmail;?></td>
                </tr>
                <tr>
                  <th>Contact #</th>
                  <td>:</td>
                  <td><?php echo $vendorsdata[0]->cMobile;?></td>
                </tr>
                <tr>
                  <th>Billing Address</th>
                  <td>:</td>
                  <td><?php echo $vendorsdata[0]->cAttention;?> <?php if($vendorsdata[0]->cStreet!= ""){echo ",".$vendorsdata[0]->cStreet;}?></td>
                </tr>
                <tr>
                  <th>City/Location</th>
                  <td>:</td>
                  <td><?php echo $vendorsdata[0]->cCity;?> <?php if($vendorsdata[0]->cState!= ""){echo ",".$vendorsdata[0]->cState;}?> <?php if($vendorsdata[0]->cZip!= ""){echo ",".$vendorsdata[0]->cZip;}?> <?php if($vendorsdata[0]->cCountry!= ""){echo ",".$vendorsdata[0]->cCountry;}?></td>
                </tr>

              </table>
            </div>
          </div>

0 个答案:

没有答案