Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'inc/fpdf181/fpdf.php';
- try{
- $stmt = $pdo->query('SELECT id,name,description, amount, price, kategorijos_id, sandelys, pics FROM prekes');
- }catch (Exception $e) {
- echo "Negaliu pridėti naujo įrašo";
- echo $e->getMessage();
- exit;
- }
- $data = $stmt->fetchAll();
- $pdf = new FPDF();
- $pdf->AddPage();
- $pdf->Ln();
- $pdf->Ln();
- $pdf->SetFont('Arial','B', 10);
- $pdf->Cell(10,7,"ID");
- $pdf->Cell(30,7,"Name");
- $pdf->Cell(45,7,"Description");
- $pdf->Cell(20,7,"Amount");
- $pdf->Cell(20,7,"Price");
- $pdf->Cell(20,7,"Kat. ID");
- $pdf->Cell(20,7,"Sandelys");
- $pdf->Cell(25,7,"Pics");
- $pdf->Ln();
- $pdf->Cell(450,7,"----------------------------------------------------------------------------------------------------------------------------------------------------------------");
- $pdf->Ln();
- foreach ($data as $item)
- {
- $id = $item['id'];
- $name = $item['name'];
- $description = $item['description'];
- $amount = $item['amount'];
- $price = $item['price'];
- $cat_id = $item['kategorijos_id'];
- $sandelys = $item['sandelys'];
- $pics = $item['pics'];
- $pdf->Cell(10,7,$id);
- $pdf->Cell(30,7,$name);
- $pdf->Cell(45,7,$description);
- $pdf->Cell(20,7,$amount);
- $pdf->Cell(20,7,$price);
- $pdf->Cell(20,7,$cat_id);
- $pdf->Cell(20,7,$sandelys);
- $pdf->Cell(25,7,$pics);
- $pdf->Ln();
- }
- $pdf->Ln();
- $pdf->Cell(450,7,"----------------------------------------------------------------------------------------------------------------------------------------------------------------");
- $pdf->Ln();
- $pdf->Output();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement