Advertisement
Guest User

Untitled

a guest
Feb 18th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.99 KB | None | 0 0
  1. <?php
  2. define('ACTION', true);
  3.  
  4. include('../../common.php');
  5. $page_title = 'Export';
  6. $mysql_tb = $userdata['user_name'];
  7.  
  8. include '../../config1.php';
  9.  
  10. $hostname=$config1['DB_HOST'];
  11. $username=$config1['DB_USERNAME'];
  12. $password=$config1['DB_PASSWORD'];
  13. $db = $config1['DB_DATABASE'];
  14.  
  15. // Create connection
  16. $conn = new mysqli($hostname, $username, $password, $db);
  17. // Check connection
  18. if ($conn->connect_error) {
  19.     die("Connection failed: " . $conn->connect_error);
  20. }
  21.  
  22. // Include the main TCPDF library (search for installation path).
  23. require_once('tcpdf_include.php');
  24.  
  25. // create new PDF document
  26. $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  27.  
  28. // set document information
  29. $pdf->SetCreator(PDF_CREATOR);
  30. $pdf->SetAuthor('asd');
  31. $pdf->SetTitle('asd');
  32. $pdf->SetSubject('asda');
  33. $pdf->SetKeywords('asd');
  34.  
  35. // set default monospaced font
  36. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  37.  
  38. // set auto page breaks
  39.  
  40.  
  41. // set image scale factor
  42. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  43.  
  44. // set some language-dependent strings (optional)
  45. if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
  46.     require_once(dirname(__FILE__).'/lang/eng.php');
  47.     $pdf->setLanguageArray($l);
  48. }
  49.  
  50. // ---------------------------------------------------------
  51.  
  52. // set font
  53. $pdf->setFont('freeserif');
  54.  
  55. // add a page
  56. $pdf->AddPage();
  57.  
  58. $pdf->setFont('freeserif');
  59.  
  60. // -----------------------------------------------------------------------------
  61. $dbh = new PDO("mysql:host=$hostname;dbname=$db", $username, $password);
  62. foreach($dbh->query("SELECT NazwaStazu, Stanowisko, Data, Miejsce, Inicjaly, Plec, NazwiskoOperatora, NazwiskaAsyst, NazwaZabiegu
  63. FROM " . $mysql_tb . "
  64. ") as $row) {
  65.  
  66.  
  67. $tbl = <<<EOD
  68. <p>MojeZabiegi.pl</p><br><br><br>
  69. <table width="700" border="1" cellpadding="4" cellspacing="0" style="border-collapse: collapse;">
  70. <tr>
  71. <td width="300" height="31">1. /nrwpisu/ </td>
  72. <td align="center" height="31"> {$row["NazwaStazu"]}</td>
  73. </tr>
  74. <tr>
  75. <td align="center" height="31"> {$row["Stanowisko"]}</td>
  76. <td align="center" height="31"> {$row["Data"]}</td>
  77. </tr>
  78. <tr>
  79. <td colspan = "2" height="31"> {$row["Miejsce"]}</td>
  80. </tr>
  81. <tr>
  82. <td align="center" height="31"> {$row["Inicjaly"]}</td>
  83. <td align="center" height="31"> {$row["Plec"]}</td>
  84. </tr>
  85. <tr>
  86. <td colspan = "2" height="31"> {$row["NazwiskoOperatora"]}</td>
  87. </tr>
  88. <tr>
  89. <td colspan = "2" height="31"> {$row["NazwiskaAsyst"]}</td>
  90. </tr>
  91. <tr>
  92. <td colspan = "2" height="31"> {$row["NazwaZabiegu"]}</td>
  93. </tr>
  94. <tr>
  95. <td height="138">11.</td>
  96. <td height="138">12.</td>
  97. </tr>
  98. </table>
  99. <br pagebreak="true"/>
  100. EOD;
  101. $pdf->writeHTML($tbl, true, false, false, false, "");
  102. }
  103.  
  104.  
  105.  
  106.  
  107. // -----------------------------------------------------------------------------
  108.  
  109. //Close and output PDF document
  110. $pdf->Output("export.pdf", "I");
  111.  
  112. //============================================================+
  113. // END OF FILE
  114. //============================================================+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement