Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.59 KB | None | 0 0
  1. <?php
  2. include 'inc/fpdf181/fpdf.php';
  3. try{
  4.     $stmt = $pdo->query('SELECT id,name,description, amount, price, kategorijos_id, sandelys, pics FROM prekes');
  5. }catch (Exception $e) {
  6.     echo "Negaliu pridėti naujo įrašo";
  7.     echo $e->getMessage();
  8.     exit;
  9. }
  10. $data = $stmt->fetchAll();
  11.  
  12. $pdf = new FPDF();
  13. $pdf->AddPage();
  14. $pdf->Ln();
  15. $pdf->Ln();
  16. $pdf->SetFont('Arial','B', 10);
  17. $pdf->Cell(10,7,"ID");
  18. $pdf->Cell(30,7,"Name");
  19. $pdf->Cell(45,7,"Description");
  20. $pdf->Cell(20,7,"Amount");
  21. $pdf->Cell(20,7,"Price");
  22. $pdf->Cell(20,7,"Kat. ID");
  23. $pdf->Cell(20,7,"Sandelys");
  24. $pdf->Cell(25,7,"Pics");
  25. $pdf->Ln();
  26. $pdf->Cell(450,7,"----------------------------------------------------------------------------------------------------------------------------------------------------------------");
  27. $pdf->Ln();
  28.  
  29.  
  30. foreach ($data as $item)
  31. {
  32.     $id = $item['id'];
  33.     $name = $item['name'];
  34.     $description = $item['description'];
  35.     $amount = $item['amount'];
  36.     $price = $item['price'];
  37.     $cat_id = $item['kategorijos_id'];
  38.     $sandelys = $item['sandelys'];
  39.     $pics = $item['pics'];
  40.  
  41.     $pdf->Cell(10,7,$id);
  42.     $pdf->Cell(30,7,$name);
  43.     $pdf->Cell(45,7,$description);
  44.     $pdf->Cell(20,7,$amount);
  45.     $pdf->Cell(20,7,$price);
  46.     $pdf->Cell(20,7,$cat_id);
  47.     $pdf->Cell(20,7,$sandelys);
  48.     $pdf->Cell(25,7,$pics);
  49.     $pdf->Ln();
  50.  
  51.  
  52. }
  53. $pdf->Ln();
  54. $pdf->Cell(450,7,"----------------------------------------------------------------------------------------------------------------------------------------------------------------");
  55. $pdf->Ln();
  56. $pdf->Output();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement