Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. <?php
  2. require('fpdf/fpdf.php');
  3.  
  4. //create a FPDF object
  5. $pdf=new FPDF();
  6.  
  7. //set font for the entire document
  8. $pdf->SetFont('Helvetica','B',20);
  9. //$pdf->SetTextColor(50,60,100);
  10.  
  11. //set up a page
  12. $pdf->AddPage('P');
  13. $pdf->SetDisplayMode('default');
  14.  
  15. //insert an image and make it a link
  16. $pdf->Image('image/logo.gif',100,10,20,0);
  17.  
  18. //display the title with a border around it
  19. $pdf->SetXY(40,30);
  20. $pdf->SetDrawColor(50,60,100);
  21. $pdf->Write(10,'The Pakistan Credit Rating Agency Limited',0,'C',0);
  22. $pdf->Line(10,40,200,40);
  23.  
  24. //Set x and y position for the main text, reduce font size and write content
  25. $pdf->SetXY (20,45);
  26. $pdf->SetFontSize(10);
  27. $pdf->SetTextColor(30,30,100);
  28. $pdf->Write(5,'NL FYI s-l4l (PSO-040515)');
  29.  
  30. $host="localhost"; // Host name
  31. $username="root"; // Mysql username
  32. $password=""; // Mysql password
  33. $db_name="test123"; // Database name
  34. $tbl_name="form"; // Table name
  35.  
  36. $con = mysqli_connect('localhost','root','');
  37. mysqli_select_db($con,"test123");
  38.  
  39. $sql="SELECT * FROM form WHERE id = '30'";
  40. $result = mysqli_query($con,$sql);
  41. while($rows= (mysqli_fetch_array($result,MYSQLI_ASSOC)))
  42. {
  43. $name = $rows['Name'];
  44. $address = $rows['Address'];
  45. $class = $rows['Designation'];
  46. $phone = $rows['Text'];
  47.  
  48. $pdf->SetXY (20,60);
  49. $pdf->SetFontSize(12);
  50. $pdf->SetTextColor(0,0,0);
  51. $pdf->Write(7,$name);
  52. $pdf->SetXY (20,65);
  53. $pdf->Write(7,$address);
  54. $pdf->SetXY (20,70);
  55. $pdf->Write(7,$class);
  56. $pdf->SetXY (20,90);
  57. $pdf->Write(7,$phone);
  58. $pdf->Ln();
  59. }
  60.  
  61. //Output the document
  62. $pdf->Output('test.pdf','I');
  63. ?>
  64.  
  65. $s = oci_parse($conn,"SELECT * FROM form WHERE id = '30'");
  66. oci_execute( $s);
  67. $result = array();
  68. while ($row = oci_fetch_array( $s, OCI_ASSOC+OCI_RETURN_NULLS)) {
  69. $result[] = $row; }
  70.  
  71. $pdf->Cell(20,5,'Name',1,0,'C',0);
  72. $pdf->Cell(20,5,$result[]['Name'],1,0,'C',0);
  73.  
  74. $pdf->Output();
  75. header("Content-Disposition: attachment; filename=filename.pdf");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement