1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
<?php
$semaineactuelle = date('W');
$bddname = 'XXX';
$hostname = 'XXX';
$username = 'XXX';
$password = 'XXX';
$db = mysqli_connect ($hostname, $username, $password, $bddname);
mysqli_select_db ('cantine', $db) ;
require('fpdf.php');
class PDF extends FPDF {
}
// Activation de la classe
$pdf = new PDF ('P','mm','A4');
$pdf->AddPage();
$pdf->SetFont('Helvetica','',11);
$pdf->SetTextColor(0);
$req1 = "SELECT * FROM menus WHERE Semaine = $semaineactuelle ";
$rep1 = mysqli_query($db, $req1);
$row1 = mysqli_fetch_array($rep1);
$position_entete = 58;
function entete_table($position_entete){
global $pdf;
$pdf->SetDrawColor(183); // Couleur du fond
$pdf->SetFillColor(221); // Couleur des filets
$pdf->SetTextColor(0); // Couleur du texte
$pdf->SetY($position_entete);
$pdf->SetX(8);
$pdf->Cell(158,8,'Date',1,0,'L',1);
$pdf->SetX(166); // 8 + 96
$pdf->Cell(10,8,'Entree1',1,0,'C',1);
$pdf->SetX(176); // 104 + 10
$pdf->Cell(24,8,'Entree2',1,0,'C',1);
$pdf->Ln(); // Retour à la ligne
}
entete_table($position_entete);
$position_detail = 66; // Position à 8mm de l'entête
$reponse = mysql_query("SELECT * FROM menus WHERE Semaine = $semaineactuelle ");
while($donnees = mysqli_fetch_array($reponse))
{
$pdf->SetY($position_detail);
$pdf->SetX(8);
$pdf->MultiCell(158,8,utf8_decode($donnees['Date']),1,'L');
$pdf->SetY($position_detail);
$pdf->SetX(166);
$pdf->MultiCell(10,8,$donnees['Entree1'],1,'C');
$pdf->SetY($position_detail);
$pdf->SetX(176);
$pdf->MultiCell(24,8,$donnes['Entree2'],1,'R');
$position_detail += 8;
}
// Nom du fichier
$nom = 'menucantine.pdf';
// Création du PDF
$pdf->Output();
?> |
Partager