1

i have a problem I want to display for each result the pdf I want, if I have 8 result, I want 8 separate pdf page. Except that I have blank page doesn't work

here is my code.

    <?php
    require('fpdf/fpdf.php');

    class PDF extends FPDF
    {

    // En-tête
    function Header()
    {
$level  = $_GET['level'];
        $level_id = $_GET['level_id'];

        include('db_connect.php');
        $requette   =   $bdd->query('   SELECT spare_parts_sn.id,spare_parts_sn.SN,spare_parts_item.description,spare_parts_item.name,level_'.$level.'.completName AS place
                                        FROM spare_parts_item,spare_parts_sn,level_'.$level.'
                                        WHERE spare_parts_sn.spare_parts_item_id = spare_parts_item.id
                                        AND spare_parts_sn.level = '.$level.'
                                        AND spare_parts_sn.level_id = '.$level_id.'
                                        AND level_'.$level.'.id = '.$level_id.'
                                        ORDER BY spare_parts_item.name ASC');

        while ($donnees =$requette->fetch()){

            $this->SetFont('Arial','',6);
            $this->Cell(34,2,''.$donnees['description'].'');
            $this->Ln(3);
            $this->Cell(6,2,''.$donnees['name'].'');
            $this->Cell(15);
            $this->Cell(15,2,''.$donnees['place'].'');
            $this->Ln(3);
            $this->Cell(4,2,'S/N : ');$this->Cell(1);$this->Cell(10,2,''.$donnees['SN'].'') ;   
            $this->Ln(3);
            $this->Cell(5,2,'ID   : ');$this->Cell(10,2,''.$donnees['id'].'');

            // $this->Image('img/'.$donnees['id'].'.png',0,16,24);

        }
     }
}
$pdf = new PDF('L','mm',array(38,24));
$pdf->SetLeftMargin(1);
$pdf->SetRightMargin(1);
$pdf->SetTopMargin(4);
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',7);
$pdf->Output();

Thanks for you help Any Ideas ?

Nosperato
  • 43
  • 5
  • 1
    Your code is vulnerable to [**SQL injection**](https://en.wikipedia.org/wiki/SQL_injection) attacks. You should use prepared statements with bound parameters, via either the [**mysqli**](https://secure.php.net/manual/en/mysqli.prepare.php) or [**PDO**](https://secure.php.net/manual/en/pdo.prepared-statements.php) drivers. [**This post**](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) has some good examples. – Alex Howansky Jun 23 '17 at 14:39
  • Thanks @AlexHowansky i know, but it's an internal network that nobody can access – Nosperato Jun 23 '17 at 14:42
  • @Nosperato do any other users have access to the system, or just you? – ctwheels Jun 23 '17 at 14:44
  • @Nosperato You only call AddPage once, so you'll only get 1 page. – ctwheels Jun 23 '17 at 14:49
  • @ctwheels Le site est mise en place sur un réseau interne, ou aucune personne peut accéder de l'extérieur. – Nosperato Jun 23 '17 at 14:53
  • @ctwheels Yes but if I integrate it in the loop it does not work either .. – Nosperato Jun 23 '17 at 14:53
  • @Nosperato Mais le réseau interne ne peut pas être accédé par ton personnel? Il n'y a rien qui dit qu'une attaque ne peut pas originer de ton réseau interne, peut-être un employé qui se trouve ennuyé? Maybe try separating it into parts: Make your code sequential (don't call the Header function and add the while loop after your `$pdf->AliasNbPages();` line, and then put `$pdf->AddPage();` inside your loop) to see if at least that outputs the correct result. Break your code down into simpler versions and see if it at the very least get you the proper output – ctwheels Jun 23 '17 at 16:15

0 Answers0