当在页面下方查询路径时,如何在php生成的pdf文件上放置徽标


how to put a logo on a php-generated pdf file when the path is queried far down the page?

我的第一个php问题。。。

我正在使用fpdf生成pdf文件。我正在做的网站的原始版本在打印出来的时候使用了一个通用的图像。我想将其更改为基于id的图像。

我的问题是在检索ID的查询运行之前声明带有图像的标头。这可能很容易修复,但不需要任何php-exp。。。

这是我的代码:

<?php
require('fpdf.php');
import_request_variables("GP", "rvar_");
$prn_con = mysql_connect('localhost', 'root', '');
mysql_select_db('db');
class PDF extends FPDF{
    function Header(){
        $this->Image('../../images/logo_generic.gif',170,8,30);
        }
    }
$pdf=new PDF();
$pdf->Open();
$tok = strtok($rvar_bestellkeys,",");
while ($tok){
    $result = mysql_query('SELECT * FROM bk WHERE bestellkey = "'.$tok.'"');
    $i = 0; 
    $fCount = mysql_num_fields($result);
    while($row=mysql_fetch_row($result)){
        while ($i < $fCount){
            $fName = mysql_field_name($result, $i); 
            $$fName = trim($row[$i]);
            $i++; 
            $strcont = strlen ($$fName);
            }
            $i=0; 
    }

其中一个查询结果是要包含在header()徽标路径中的ID。

问题
如何从while-loop内部设置header()路径?循环打印出文档(单页/多页),每一页都应该有右上角的徽标。

谢谢你的帮助!

编辑:
以下是整个php脚本:

<?php
require('fpdf.php');
import_request_variables("GP", "rvar_");
$prn_con = mysql_connect('localhost', 'root', '');
mysql_select_db('db');
$resultsprache = mysql_query("SELECT * FROM sprachen WHERE sprache = '".$rvar_sprache."'");
while($row=mysql_fetch_row($resultsprache)){
    $fName = trim($row[2]);
    $$fName = trim($row[3]);
    }
$FileN = $tx_bestellung. '_'.date("YmdHis").'.pdf';
$title = $tx_bestellung;
class PDF extends FPDF{
    function Header(){
        $this->Image('../../images/logo_klein.gif',170,8,30);
        }
    }
 $pdf=new PDF();
 $pdf->Open();
 $pdf->AliasNbPages();
 $pdf->AddPage();
 $pdf->SetTitle($title);
 $pdf->SetFont('Arial','',8);
 $tok = strtok($rvar_bestellkeys,",");
 while ($tok){
    $result = mysql_query('SELECT * FROM bK WHERE bestellkey = "'.$tok.'"');
    $i = 0; 
    $fCount = mysql_num_fields($result);
    while($row=mysql_fetch_row($result)){
        while ($i < $fCount){
            $fName = mysql_field_name($result, $i); 
            $$fName = trim($row[$i]);
            $i++; 
            $strcont = strlen ($$fName);
            }
        $i=0; 
    }
$pdf->Cell(190,7,$tx_bestellung. " " .$tx_nr. " " .$bestellkey,0,1,'L');
    $pdf->Ln(8);
$pdf->Cell(190,5,$tx_verkaeufer,0,1);
$pdf->Cell(30,4,'ILN/GLN:',0,0);
$pdf->Cell(65,4,$vk_iln,0,1);
$pdf->Cell(30,4,$tx_firma. ':',0,0);
$pdf->Cell(65,4,$vk_firma,0,0);
$pdf->Cell(30,4,$tx_bestellnummer. ':',0,0);
$pdf->Cell(65,4,$bestellkey,0,1);
$pdf->Cell(30,4,$tx_adresse. ':',0,0);
$pdf->Cell(65,4,$vk_adresse,0,0);
$pdf->Cell(30,4,$bestelldatum. ':',0,0);
    $bestelldatum = (substr($bestelldatum, 8,2)).'.'.(substr($bestelldatum, 5, -3)).'.'.(substr($bestelldatum, 0, -6));
$pdf->Cell(65,4,$bestelldatum,0,1);
$pdf->Cell(30,4,$tx_plz. ', ' .$tx_ort. ':',0,0);
$pdf->Cell(65,4,$vk_plz.' '.$vk_ort,0,0);
.... 
$i=0; 
$result = mysql_query('SELECT * FROM bP WHERE bestellkey = "'.$tok.'"');
$fCount = mysql_num_fields($result);
$pdf->Cell(9,8,$tx_pos,1,0,'C');
$pdf->Cell(23,8,"EAN/GTIN",1,0,'C');
$pdf->Cell(43,8,$tx_bezeichnung,1,0,'C');
$pdf->Cell(10,8,$tx_groesse,1,0,'C');
$pdf->Cell(10,8,$tx_farbe,1,0,'C');
$pdf->Cell(15,8,$tx_preis,1,0,'C');
$pdf->Cell(12,8,$tx_einheit,1,0,'C');
$pdf->Cell(15,8,$tx_menge,1,0,'C');
$pdf->Cell(15,8,$tx_menge. "'n" .$tx_bestaetigt,1,0,'C');
$pdf->Cell(18,8,$tx_summe,1,1,'C');
...
$tok = strtok(",");
if($tok != ""){
    $pdf->AddPage();
}
}
mysql_close($prn_con);
$pdf->Output($FileN, 'D');
?>

快速且相当脏,但应该可以工作:

    <?php
    require('fpdf.php');
    import_request_variables("GP", "rvar_");
    $prn_con = mysql_connect('localhost', 'root', '');
    mysql_select_db('db');
    $resultsprache = mysql_query("SELECT * FROM sprachen WHERE sprache = '".$rvar_sprache."'");
    while($row=mysql_fetch_row($resultsprache)){
        $fName = trim($row[2]);
        $$fName = trim($row[3]);
        }
    $FileN = $tx_bestellung. '_'.date("YmdHis").'.pdf';
    $title = $tx_bestellung;
    $tok = strtok($rvar_bestellkeys,",");
    while ($tok){
        $result = mysql_query('SELECT * FROM bK WHERE bestellkey = "'.$tok.'"');
        $i = 0; 
        $fCount = mysql_num_fields($result);
        while($row=mysql_fetch_row($result)){
            if ($something === true) {
                $my_magic_id = $row['my_magic_id_column'];
            }
            if (isset($my_magic_id) && !class_exists('PDF')) {
                class PDF extends FPDF{
                    function Header(){
                        global $my_magic_id;
                        $this->Image('../../images/logo_klein.gif',170,8,30);
                        }
                    }
                $pdf=new PDF();
                $pdf->Open();
                $pdf->AliasNbPages();
                $pdf->AddPage();
                $pdf->SetTitle($title);
                $pdf->SetFont('Arial','',8);
            }
            while ($i < $fCount){
                $fName = mysql_field_name($result, $i); 
                $$fName = trim($row[$i]);
                $i++; 
                $strcont = strlen ($$fName);
                }
            $i=0; 
        }
    $pdf->Cell(190,7,$tx_bestellung. " " .$tx_nr. " " .$bestellkey,0,1,'L');
        $pdf->Ln(8);
    $pdf->Cell(190,5,$tx_verkaeufer,0,1);
    $pdf->Cell(30,4,'ILN/GLN:',0,0);
    $pdf->Cell(65,4,$vk_iln,0,1);
    $pdf->Cell(30,4,$tx_firma. ':',0,0);
    $pdf->Cell(65,4,$vk_firma,0,0);
    $pdf->Cell(30,4,$tx_bestellnummer. ':',0,0);
    $pdf->Cell(65,4,$bestellkey,0,1);
    $pdf->Cell(30,4,$tx_adresse. ':',0,0);
    $pdf->Cell(65,4,$vk_adresse,0,0);
    $pdf->Cell(30,4,$bestelldatum. ':',0,0);
        $bestelldatum = (substr($bestelldatum, 8,2)).'.'.(substr($bestelldatum, 5, -3)).'.'.(substr($bestelldatum, 0, -6));
    $pdf->Cell(65,4,$bestelldatum,0,1);
    $pdf->Cell(30,4,$tx_plz. ', ' .$tx_ort. ':',0,0);
    $pdf->Cell(65,4,$vk_plz.' '.$vk_ort,0,0);
    .... 
    $i=0; 
    $result = mysql_query('SELECT * FROM bP WHERE bestellkey = "'.$tok.'"');
    $fCount = mysql_num_fields($result);
    $pdf->Cell(9,8,$tx_pos,1,0,'C');
    $pdf->Cell(23,8,"EAN/GTIN",1,0,'C');
    $pdf->Cell(43,8,$tx_bezeichnung,1,0,'C');
    $pdf->Cell(10,8,$tx_groesse,1,0,'C');
    $pdf->Cell(10,8,$tx_farbe,1,0,'C');
    $pdf->Cell(15,8,$tx_preis,1,0,'C');
    $pdf->Cell(12,8,$tx_einheit,1,0,'C');
    $pdf->Cell(15,8,$tx_menge,1,0,'C');
    $pdf->Cell(15,8,$tx_menge. "'n" .$tx_bestaetigt,1,0,'C');
    $pdf->Cell(18,8,$tx_summe,1,1,'C');
    ...
    $tok = strtok(",");
    if($tok != ""){
        $pdf->AddPage();
    }
    }
    mysql_close($prn_con);
    $pdf->Output($FileN, 'D');
    ?>