Bonjour à tous,
Je post pour demander comment on fait pour afficher des variables qu'on voudrait récupérer dans une base de données, ainsi qu'une variable de session.
Je débute en FPDF, et ne vois pas comment faire.
J'ai fait un premier script :
<?php session_start(); $id = $_SESSION['id'];
//récupération des données client
mysql_connect('****','****','****');
mysql_select_db('****');
$recup = mysql_query("SELECT identifiant, denomsociale, adresse0, adresse1, adresse2, codepostal, ville FROM infos_clients WHERE id='$id'");
$infos = mysql_fetch_array($recup);
require('fpdf.php');
class PDF extends FPDF
{
//En-tête
function Header()
{
$this->Image('baniere_facture.jpg',10,3,190);
$this->Ln(30);
$this->SetFont('Times','',10);
$this->Cell(100,5,'Centre d\'affaires Le Palatium',0,1);
$this->Cell(100,5,'126 impasse Juvénal',0,1);
$this->Cell(100,5,'30900 NÎMES',0,0);
$this->Cell(90,5,$infos['denomsociale'],0,1);
$this->Cell(100,5,'Téléphone : 04 66 67 86 93',0,0);
$this->Cell(90,5,$infos['adresse0'],0,1);
$this->Cell(100,5,'Fax : 04 66 67 86 47',0,0);
if ($infos['adresse1'] != NULL) { $this->Cell(90,5,$infos['adresse1'],0,1);
if ($infos['adresse2'] != NULL) { $this->Cell(90,5,$infos['adresse2'],0,1); } else {}} else {}
$this->Cell(90,5,$infos['codepostal'].' '.$infos['ville'],0,1);
$this->Cell(0,5,'Votre identifiant chez nous : '.$infos['identifiant'],0,1);
$this->Ln(20);
}
//Pied de page
function Footer()
{
$this->SetY(-10);
$this->SetFont('Times','I',8);
$this->Cell(0,10,'E.U.R.L. au capital de 15 000 € / Siret : 501 309 942 00016 / NAF : 503B',0,0);
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'R');
}
}
//Instanciation de la classe dérivée
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
for($i=1;$i<=50;$i++)
$pdf->Cell(0,10,'Impression de la ligne numéro '.$i,0,1);
$pdf->Output();
?>
_____________________________________________________________________
et j'ai essayé autrement :
<?php session_start(); $id = $_SESSION['id'];
//récupération des données client
function recuperation($info)
{
mysql_connect('****','****','****');
mysql_select_db('****');
$recup = mysql_query("SELECT identifiant, denomsociale, adresse0, adresse1, adresse2, codepostal, ville FROM infos_clients WHERE id='$id'");
$infos = mysql_fetch_array($recup);
return $infos;
}
require('fpdf.php');
class PDF extends FPDF
{
//En-tête
function Header()
{
$infos = recuperation($id);
$this->Image('baniere_facture.jpg',10,3,190);
$this->Ln(30);
$this->SetFont('Times','',10);
$this->Cell(100,5,'Centre d\'affaires Le Palatium',0,1);
$this->Cell(100,5,'126 impasse Juvénal',0,1);
$this->Cell(100,5,'30900 NÎMES',0,0);
$this->Cell(90,5,$denomsociale,0,1);
$this->Cell(100,5,'Téléphone : 04 66 67 86 93',0,0);
$this->Cell(90,5,$adresse0,0,1);
$this->Cell(100,5,'Fax : 04 66 67 86 47',0,0);
if ($adresse1 != NULL) { $this->Cell(90,5,$adresse1,0,1);
if ($adresse2 != NULL) { $this->Cell(90,5,$adresse2,0,1); } else {}} else {}
$this->Cell(90,5,$codepostal.' '.$ville,0,1);
$this->Cell(0,5,'Votre identifiant chez nous : '.$identifiant.$id,0,1);
$this->Ln(20);
}
//Pied de page
function Footer()
{
$this->SetY(-10);
$this->SetFont('Times','I',8);
$this->Cell(0,10,'E.U.R.L. au capital de 15 000 € / Siret : 501 309 942 00016 / NAF : 503B',0,0);
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'R');
}
}
//Instanciation de la classe dérivée
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
for($i=1;$i<=50;$i++)
$pdf->Cell(0,10,'Impression de la ligne numéro '.$i,0,1);
$pdf->Output();
?>
_______________________________________________________
Voilà, merci pour votre aide
Configuration: Windows XP
Firefox 2.0.0.11