lundi 27 avril 2020

FDPF PHP retrieve specific data from database

I'm trying to get the invoice bill based on the transaction code, however the output will display all the data from the database but I just want the data of the transaction code. Can help me to see where my coding have error?

<?php
require 'fpdf17/fpdf.php';
include('include/config.php');
$transcode=intval($_GET['transcode']);
$pdf = new FPDF();
$pdf-> AddPage();
$pdf->SetFont('Helvetica', 'B', 12);

$pdf-> Cell (58,5,'Transaction Code',1,0,'C');
$pdf-> Cell (58,5,'Customer Name ',1,0,'C');
$pdf-> Cell (58,5,'Date Of Order',1,0,'C');
$name = mysqli_query($con, "SELECT transaction_code, order_by, order_date FROM design_orders_view WHERE transaction_code= $transcode") or die("database error:". mysqli_error($con));
if(mysqli_num_rows($name)>0)
{
while($row=mysqli_fetch_array($name))
      {
        $pdf-> Ln(5);
$pdf-> Cell (58,5,$row['transaction_code'],1,0,'C');
$pdf-> Cell (58,5,$row['order_by'],1,0,'C');
$pdf-> Cell (58,5,$row['order_date'],1,0,'C');
      }}

$pdf-> Ln(10);
$pdf-> Cell (180,5,'Design T-Shirt Order',1,0,'C');
$pdf-> Ln(5);
$pdf-> Cell (30,5,'S size',1,0,'C');
$pdf-> Cell (30,5,'M size',1,0,'C');
$pdf-> Cell (30,5,'L size',1,0,'C');
$pdf-> Cell (30,5,'XL size',1,0,'C');
$pdf-> Cell (30,5,'XXL size',1,0,'C');
$pdf-> Cell (30,5,'Total Quantity',1,0,'C');

$size = mysqli_query($con, "SELECT small_size, medium_size, large_size, xlarge_size, xxlarge_size, total FROM design_orders_view WHERE transaction_code= $transcode") or die("database error:". mysqli_error($con));
if(mysqli_num_rows($size)>0)
{
while($row=mysqli_fetch_array($size))
      {
        $pdf-> Ln(5);
$pdf-> Cell (30,5,$row['small_size'],1,0,'C');
$pdf-> Cell (30,5,$row['medium_size'],1,0,'C');
$pdf-> Cell (30,5,$row['large_size'],1,0,'C');
$pdf-> Cell (30,5,$row['xlarge_size'],1,0,'C');
$pdf-> Cell (30,5,$row['xxlarge_size'],1,0,'C');
$pdf-> Cell (30,5,$row['total'],1,0,'C');
      }}
$pdf->Output();
  ?>




Aucun commentaire:

Enregistrer un commentaire