sql >> Databasteknik >  >> RDS >> Mysql

exportera mysql-databastabellinnehåll till en PDF-fil med php

    <?php
require('fpdf17/fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',10);
$pdf->Ln();
$pdf->Ln();
$pdf->SetFont('times','B',10);
$pdf->Cell(25,7,"Stud ID");
$pdf->Cell(30,7,"Student Name");
$pdf->Cell(40,7,"Address");
$pdf->Cell(30,7,"Class");
$pdf->Cell(30,7,"Phone No");
$pdf->Cell(30,7,"E-mail");
$pdf->Ln();
$pdf->Cell(450,7,"----------------------------------------------------------------------------------------------------------------------------------------------------------------------");
$pdf->Ln();

        include ('db.php');
        $sql = "SELECT studid,name,address,class,phone,email FROM studinfo";
        $result = mysql_query($sql);

        while($rows=mysql_fetch_array($result))
        {
            $studid = $rows[0];
            $name = $rows[1];
            $address = $rows[2];
            $class = $rows[3];
            $phone = $rows[4];
            $email = $rows[5];
            $pdf->Cell(25,7,$studid);
            $pdf->Cell(30,7,$name);
            $pdf->Cell(40,7,$address);
            $pdf->Cell(30,7,$class);
            $pdf->Cell(30,7,$phone);
            $pdf->Cell(30,7,$email); 
            $pdf->Ln(); 
        }
$pdf->Output();
?>


  1. En annan mysqld-server som körs på port 3306-fel

  2. Hur SQLite Avg() fungerar

  3. Hur uppdaterar du MySQL-konfigurationsfilen utan att starta om?

  4. få JOIN-tabellen som en rad resultat med PostgreSQL/NodeJS