<?php
ob_start();
require( 'fpdf.php' );
$pdf = new FPDF();
$pdf->AddPage();
$pdf->Open();
$con = mysqli_connect( "localhost", "root", "", "my_db" );
// Check connection
if ( mysqli_connect_errno() ) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query( $con, "SELECT * FROM Persons" );
while ( $row = mysqli_fetch_array( $result ) ) {
$fname = $row['FirstName'];
$lname = $row['LastName'];
$age = $row['Age'];
$pdf->Cell( "{$fname}" );
$pdf->Cell( "{$lname}" );
$pdf->Cell( "{$age}" );
}
$pdf->Output();
?>
nidhinmohanan 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.