Hadi1989

Untitled

Nov 30th, 2018
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. <?php
  2. require_once 'dompdf/autoload.inc.php';
  3.  
  4.  
  5. use Dompdf\Dompdf;
  6.  
  7.  
  8.  
  9. $document = new Dompdf();
  10.  
  11.  
  12. $output = "
  13. <html>
  14.     <head>
  15.         <link rel='stylesheet' type='text/css' href='css/bootstrap.css'/>
  16.     </head>
  17. <body>
  18. <table class='table table-bordered'>
  19.     <thead class='alert-info'>
  20.         <tr>
  21.             <th>Firstname</th>
  22.             <th>Middlename</th>
  23.             <th>Lastname</th>
  24.             <th>Address</th>
  25.             <th>Civil Status</th>
  26.         </tr>
  27.     </thead>
  28. ";
  29.  
  30. require_once 'conn.php';
  31.  
  32. $query = $conn->query("SELECT * FROM `member` ORDER BY `lastname` ASC") or die($conn->error());
  33.  
  34. while($fetch = $query->fetch_array()){
  35.    
  36. $output .= '
  37.     <tbody style="background-color:#fff;"> 
  38.         <tr>
  39.             <td>'.$fetch['firstname'].'</td>
  40.             <td>'.$fetch['middlename'].'</td>
  41.             <td>'.$fetch['lastname'].'</td>
  42.             <td>'.$fetch['address'].'</td>
  43.             <td>'.$fetch['civil_status'].'</td>
  44.         </tr>
  45.     </tbody>
  46. ';
  47.  
  48. }
  49.  
  50.  
  51. $output .= '</table></body></html>';
  52.  
  53. $document->loadHtml($output);
  54.  
  55. $document->setPaper('A4', 'landscape');
  56.  
  57. $document->render();
  58.  
  59. $document->stream("", array("Attachment"=>0));
  60.  
  61. ?>
Advertisement
Add Comment
Please, Sign In to add comment