<?php
require('fpdf.php');
$link=mysql_connect("DNS", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
class PDF extends FPDF
{
//Load data
function LoadData()
{
$query = "SELECT fields from table where condition order by id";
$Result = mysql_query( $query );
$size=mysql_num_rows($Result);
for($i=0;$i<$size;$i++)
$row[$i] = mysql_fetch_row($Result);
mysql_free_result($Result);
$data=array();
for($i=0;$i<$size;$i++)
{
$data[] = $row[$i];
}
return $data;
}
function tableResults($header,$data)
{
//Column widths
//Header
//for
//Data
{
//foreach
}
}
function Header()
{
//header code
}
function Footer()
{
//footercode
}
}
$pdf=new PDF();
$pdf->AddPage('P','A4');
$data=$pdf->LoadData();
if (test $data)
{
//if there is data print queryResult
}
else
{
//if there is no data resume next
}
$pdf->Output();
?>
Yes!
Actual testing condition is:
!empty($data)
if true query result
if false resume next
It works in the first tests. I am not sure of this, because the result is inverted to the syntax:
!empty returns true if there is data, false if there isn’t.
Can I rely on !empty the way it is, or do you suggest another approach?
Thank you. The thing is (!empty($data)) returns true if the array is full, else returns false.
My doubt was that it would be the correct way to always obtain the required result, true=-1, false=0.
So far what ever it returns, returns inversed to my expectation.
Thank you again.
Yes testing the condition. It is good practice. I will not go any further with it, since the result I am obtaining is quite enough, and occurrences have happened so far. Thank you for your assurances.