2011-12-29 3 views
0

私はpdpdファイルを作成するためにDOMpdfを使用しています。次の表を印刷するには、変数として取得してから、それをコントローラに送信する必要があります。ちょうど$value = "Some value(in this place I want the following table) ";のようなものですが、ここでは、データを取り込むためのPHPスクリプトがある場合、このテーブル全体をどのように変数に入れるのかよくわかりません。HTMLテーブルをPHP変数として取得するには?

助けてください。

<?php if(count($records) > 0) { ?> 
      <h1> Batch Name: <?php echo "$batchname";?> </h1> 
      <table id="table1" class="gtable sortable"> 
      <thead> 
        <tr> 
         <th>S.N</th> 
         <th>Student ID</th> 
         <th>Exam Date</th> 
         <th>Exam Type</th> 
         <th>Subject</th> 
         <th>Total Mark</th> 
         <th>Highest Mark</th> 
         <th>Obtained Mark</th> 
         <th>GPA</th> 
         <th>Grade</th> 
         <th>Status</th> 

        </tr> 
      </thead> 
      <tbody> 
      <?php $i = $this->uri->segment(3) + 0; foreach ($records as $row){ $i++; ?> 


        <tr> 
         <td><?php echo $i; ?>.</td> 

         <td><a href="<?php echo base_url(); ?>viewbatch/get/<?php echo $row['studentid']; ?>"><?php echo $row['studentid'];?></a></td> 
         <td><?php echo $row['examdate'];?></td> 
         <td><?php echo $row['examtype'];?></td> 

         <td><?php echo $row['subject'];?></td> 
         <td><?php echo $row['totalmark'];?></td> 

         <td><?php echo $row['highestmark'];?></td> 
         <td><?php echo $row['obtainedmark'];?></td> 

         <td><?php echo $row['gradepoint'];?></td> 
         <td><?php echo $row['grade'];?></td> 
         <td><?php echo $row['status'];?></td> 



        </tr> 
      <?php } ?> 

      </tbody> 
      </table> 
+1

私の応答をhttp://stackoverflow.com/questions/8657831/how-to-after-pulling-info-from-db-send-an-email/8657946#8657946でチェックすると、PHPに伝える必要がありますデータをブラウザに送信する代わりにバッファリングし、HTMLを通常の方法で描画し、PHPからバッファリングされたコンテンツを文字列として返すようにします。その時点で、あなたが作成したHTMLを含む文字列が返されます。 – Yaniro

答えて

2

をこのコードを試してみてください。

<?php 
ob_start(); 
if(count($records) > 0) { ?> 
      <h1> Batch Name: <?php echo "$batchname";?> </h1> 
      <table id="table1" class="gtable sortable"> 
      <thead> 
        <tr> 
         <th>S.N</th> 
         <th>Student ID</th> 
         <th>Exam Date</th> 
         <th>Exam Type</th> 
         <th>Subject</th> 
         <th>Total Mark</th> 
         <th>Highest Mark</th> 
         <th>Obtained Mark</th> 
         <th>GPA</th> 
         <th>Grade</th> 
         <th>Status</th> 

        </tr> 
      </thead> 
      <tbody> 
      <?php $i = $this->uri->segment(3) + 0; foreach ($records as $row){ $i++; ?> 


        <tr> 
         <td><?php echo $i; ?>.</td> 

         <td><a href="<?php echo base_url(); ?>viewbatch/get/<?php echo $row['studentid']; ?>"><?php echo $row['studentid'];?></a></td> 
         <td><?php echo $row['examdate'];?></td> 
         <td><?php echo $row['examtype'];?></td> 

         <td><?php echo $row['subject'];?></td> 
         <td><?php echo $row['totalmark'];?></td> 

         <td><?php echo $row['highestmark'];?></td> 
         <td><?php echo $row['obtainedmark'];?></td> 

         <td><?php echo $row['gradepoint'];?></td> 
         <td><?php echo $row['grade'];?></td> 
         <td><?php echo $row['status'];?></td> 



        </tr> 
      <?php } ?> 

      </tbody> 
      </table> 
<?php 
$output = ob_get_clean(); 
?> 

乾杯!

関連する問題