Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    struggling to print selected data in a table to pdf

    Good Day,

    Please can anyone assist i'm trying to print a table with only selected query's data to pdf using fpdf, my pdf runs but doesn't display the table data.

    PHP Code:
    $query_rsSpectra "SELECT *
    FROM spectra 
    INNER JOIN detai
    USING (sfref)
    WHERE spectra.sfref = 'SPM0001'"

    $rsSpectra mysql_query($query_rsSpectra$spectra) or die(mysql_error());
    $row_rsSpectra mysql_fetch_assoc($rsSpectra);

    if (isset(
    $_GET['totalRows_rsSpectra'])) {
      
    $totalRows_rsSpectra $_GET['totalRows_rsSpectra'];
    } else {
      
    $all_rsSpectra mysql_query($query_rsSpectra);
      
    $totalRows_rsSpectra mysql_num_rows($all_rsSpectra);
    }
    while(
    $row_rsSpectra mysql_fetch_assoc($all_rsSpectra))
    {
    $pdf = new FPDF('L''mm''A4');
    $pdf -> AddPage();
    $pdf -> SetFont ('Arial','B'10);
    $pdf-> Image('xdsl.jpg',10,6,50);
    $pdf-> Image('GL.jpg',240,6,35);
    $pdf -> Ln(40);
    $pdf -> Cell (25,5,"Reference :");
    $pdf -> Cell (80,5,$row_rsSpectra['sfref'] ,1);
    $pdf -> Cell (80,5,$row_rsSpectra['claimnumber'] ,1);
    $pdf -> Ln(40);
    $pdf -> Cell (80,5,$row_rsSpectra['surnam'] ,1);
    $pdf -> Ln(40);
    //initialize counter
    $i 0;

    //Set maximum rows per page
    $max 25;

    //Set Row Height
    $row_height 6;

    while(
    $row mysql_fetch_array($all_rsSpectra))
    {
        
    //If the current row is the last one, create new page and print column title
        
    if ($i == $max)
        {
            
    $pdf->AddPage();

            
    //print column titles for the current page
            
    $pdf->SetY($y_axis_initial);
            
    $pdf->SetX(25);
            
    $pdf->Cell(30,6,'Claim',1,0,'L',1);
            
    $pdf->Cell(100,6,'Provider',1,0,'L',1);
            
    $pdf->Cell(30,6,'Paid Supplier',1,0,'R',1);       
            
    //Set $i variable to 0 (first row)
            
    $i 0;
        }

        
    $claim $all_rsSpectra['claimnumber'];
        
    $name $all_rsSpectra['providername'];
        
    $supplier $all_rsSpectra['paidsuppl'];

        
    $pdf->SetY(5);
        
    $pdf->SetX(25);
        
    $pdf->Cell(30,6,$claim,1,0,'L',1);
        
    $pdf->Cell(100,6,$supplier,1,0,'L',1);
        
    $pdf->Cell(30,6,$name,1,0,'R',1);

        
    //Go to next row
        
    $i $i 1;
    }
    //mysql_close($link);
    $pdf -> Output($row_rsSpectra['sfref'], 'I');
    }
    ?> 
    Last edited by Inigoesdr; 09-12-2011 at 05:20 PM.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,346
    Thanks
    60
    Thanked 527 Times in 514 Posts
    With 5 posts you've surely had time to read the sticky topic about [php] tags?

    If not there is a link in my signature.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •