Harry H Arends op 27/07/2017 15:23:06
Op de pagina staat onderstaand script. Omdat ik voordat een PDF wordt gemaakt komt TCPDF met een foutmelding.
<?php
// Vul hier een rapport specifiek clausule in.
if($_GET[sort] == "stable") {
$sort = "2010Combination.stableNumber";
}
elseif($_GET[sort] == "combination")
{
$sort = "2010Combination.compNumber";
}
elseif($_GET[sort] == "nocell")
{
$sqlCombiWHERE = "WHERE 2010Combination.cellGroom = ' ' ";
}
else {
$sort = "horse.complete_name";
$sqlCombiWHERE = " ";
}
echo "ORDER = ".$sort."<br />";
echo "WHERE = ".$sqlCombiWHERE;
show_array($_GET);
//show_array($_POST);
//show_array($_SESSION);
$report = $_GET['report']; // report name/template
$horseID = $_GET['horseFEIid']; // Horse FEI passport number/id
$sqlCombiBASIC = "
SELECT person.*, horse.*, 2010Combination.*, country.* , country.*
FROM FEIPerson AS person
JOIN 2010Combination ON person.fei_id = 2010Combination.personFEIid
JOIN FEIHorse horse ON horse.fei_id = 2010Combination.horseFEIid
JOIN country ON country.ISO_A3 = person.competing_for_country ";
$sqlCombiORDER = "
ORDER BY person.competing_for_country, 2010Combination.compNumber , ". $sort. " ASC "; // not always neede, can do no harm
$sqlCombination = $sqlCombiBASIC . $sqlCombiWHERE . $sqlCombiORDER;
if(!$Result = mysqli_query($dblink, $sqlCombination)) {
$html = "There is een error opening table for ". $report. "; ".mysqli_error($dblink)."<br />";
// for debug only
$html .= "<br/>";
$html .= $sqlCombiBASIC;
$html .= "<br/>";
$html .= $sqlCombiWHERE ;
$html .= "<br/>";
$html .= $sqlCombiORDER;
$html .= "<br/>";
$pdf->writeHTML($html, true, false, true, false, ' ');
} else {
$numberCombination = mysqli_affected_rows($dblink); // must be at least 1
// ---------------------------------------------------------
$pdf->setJPEGQuality(75);// set JPEG quality
$pdf->SetFont('helvetica', '', 8);// set font
$pdf->AddPage();// add a page
// get all the needed data from the tables
if($_GET[sort] == "stable") $sort = "2010Combination.stableNumber";
elseif($_GET[sort] == "combination") $sort = "2010Combination.compNumber";
else $sort = "horse.complete_name";
$Result = mysqli_query($dblink, $sqlCombination);
if(!$Result) {
$html = 'There is een error opening table for listing Combinations; '.mysqli_error($dblink);
$pdf->writeHTML($html, true, false, true, false, ' ');
} else {}
$numberCombination = mysqli_affected_rows($dblink);
$html = '<table cellspacing="0" cellpadding="0" border="0">
<tr>
<th width="25" style="border-bottom:solid 4px 0,1,0,0"><font size="+1.5"><b>St.</b></font></th>
<th width="35" style="border-bottom:solid 4px 0,1,0,0"><font size="+1.5"><b>Cmb.</b></font></th>
<th width="300" style="border-bottom:solid 4px 0,1,0,0"><font size="+1.5"><b>Horse</b></font></th>
<th width="150" style="border-bottom:solid 4px 0,1,0,0"><font size="+1.5"><b>Groom</b></font></th>
<th width="50" style="border-bottom:solid 4px 0,1,0,0"><font size="+1.5"><b>Carv.</b></font></th>
<th width="75" style="border-bottom:solid 4px 0,1,0,0"><font size="+1">Phone</font></th>
</tr>
</table>';
$pdf->writeHTMLCell(0, 0, '', '', $html, 'B', 1, 0, true, 'L', false);
if(!$result || ($numberCombination < 0)) {
}
elseif($numberCombination > 0) {
for($i=0; $i<$numberCombination; $i++) {
$Totaal = mysqli_fetch_assoc($Result);
$family_name = ucfirst(strtolower($Totaal['family_name']));
$first_name = ucfirst(strtolower($Totaal['first_name']));
if($Totaal['gender_p'] == "Male"){ $namef = 'Mr. '.$first_name.' '.$family_name;} else { $namef = 'Ms. '.$first_name.' '.$family_name; }
$html = '
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="25">'.$Totaal['stableNumber'].'</td>
<td width="35">'.$Totaal['compNumber'].'</td>
<td width="300">'.$Totaal['complete_name'].' ('.$Totaal['competing_for_country'].')</td>
<td width="150">'.$Totaal['nameGroom'].'</td>';
if($Totaal['caravanNumber'] == '0') {
$html .= ' <td width="50">---</td>';
} else {
$html .= ' <td width="50">'.$Totaal['caravanNumber'].'</td>';
}
$html .= '
<td width="75">+'.$Totaal['cellGroom'].'</td>
</tr>
</table>';
$pdf->writeHTML($html, false, false, true, false, ' ');
}
} else {
$html = 'No records found.';
$pdf->writeHTML($html, true, false, true, false, ' ');
}
}
// ---------------------------------------------------------
//============================================================+
// END OF FILE
//============================================================+
?>
[size=xsmall]Toevoeging op 27/07/2017 15:29:46:[/size]
[quote="Harry H Arends op 27/07/2017 15:23:06"]
Op de pagina staat onderstaand script. Omdat ik voordat een PDF wordt gemaakt komt TCPDF met een foutmelding.
<?php
// Vul hier een rapport specifiek clausule in.
if($_GET[sort] == "stable") {
$sort = "2010Combination.stableNumber";
}
elseif($_GET[sort] == "combination")
{
$sort = "2010Combination.compNumber";
}
elseif($_GET[sort] == "nocell")
{
$sqlCombiWHERE = "WHERE 2010Combination.cellGroom = ' ' ";
}
else {
$sort = "horse.complete_name";
$sqlCombiWHERE = " ";
}
echo "ORDER = ".$sort."<br />";
echo "WHERE = ".$sqlCombiWHERE;
show_array($_GET);
//show_array($_POST);
//show_array($_SESSION);
$report = $_GET['report']; // report name/template
$horseID = $_GET['horseFEIid']; // Horse FEI passport number/id
$sqlCombiBASIC = "
SELECT person.*, horse.*, 2010Combination.*, country.* , country.*
FROM FEIPerson AS person
JOIN 2010Combination ON person.fei_id = 2010Combination.personFEIid
JOIN FEIHorse horse ON horse.fei_id = 2010Combination.horseFEIid
JOIN country ON country.ISO_A3 = person.competing_for_country ";
$sqlCombiORDER = "
ORDER BY person.competing_for_country, 2010Combination.compNumber , ". $sort. " ASC "; // not always neede, can do no harm
$sqlCombination = $sqlCombiBASIC . $sqlCombiWHERE . $sqlCombiORDER;
if(!$Result = mysqli_query($dblink, $sqlCombination)) {
$html = "There is een error opening table for ". $report. "; ".mysqli_error($dblink)."<br />";
// for debug only
$html .= "<br/>";
$html .= $sqlCombiBASIC;
$html .= "<br/>";
$html .= $sqlCombiWHERE ;
$html .= "<br/>";
$html .= $sqlCombiORDER;
$html .= "<br/>";
$pdf->writeHTML($html, true, false, true, false, ' ');
} else {
$numberCombination = mysqli_affected_rows($dblink); // must be at least 1
// ---------------------------------------------------------
$pdf->setJPEGQuality(75);// set JPEG quality
$pdf->SetFont('helvetica', '', 8);// set font
$pdf->AddPage();// add a page
// get all the needed data from the tables
if($_GET[sort] == "stable") $sort = "2010Combination.stableNumber";
elseif($_GET[sort] == "combination") $sort = "2010Combination.compNumber";
else $sort = "horse.complete_name";
$Result = mysqli_query($dblink, $sqlCombination);
if(!$Result) {
$html = 'There is een error opening table for listing Combinations; '.mysqli_error($dblink);
$pdf->writeHTML($html, true, false, true, false, ' ');
} else {}
$numberCombination = mysqli_affected_rows($dblink);
$html = '<table cellspacing="0" cellpadding="0" border="0">
<tr>
<th width="25" style="border-bottom:solid 4px 0,1,0,0"><font size="+1.5"><b>St.</b></font></th>
<th width="35" style="border-bottom:solid 4px 0,1,0,0"><font size="+1.5"><b>Cmb.</b></font></th>
<th width="300" style="border-bottom:solid 4px 0,1,0,0"><font size="+1.5"><b>Horse</b></font></th>
<th width="150" style="border-bottom:solid 4px 0,1,0,0"><font size="+1.5"><b>Groom</b></font></th>
<th width="50" style="border-bottom:solid 4px 0,1,0,0"><font size="+1.5"><b>Carv.</b></font></th>
<th width="75" style="border-bottom:solid 4px 0,1,0,0"><font size="+1">Phone</font></th>
</tr>
</table>';
$pdf->writeHTMLCell(0, 0, '', '', $html, 'B', 1, 0, true, 'L', false);
if(!$result || ($numberCombination < 0)) {
}
elseif($numberCombination > 0) {
for($i=0; $i<$numberCombination; $i++) {
$Totaal = mysqli_fetch_assoc($Result);
$family_name = ucfirst(strtolower($Totaal['family_name']));
$first_name = ucfirst(strtolower($Totaal['first_name']));
if($Totaal['gender_p'] == "Male"){ $namef = 'Mr. '.$first_name.' '.$family_name;} else { $namef = 'Ms. '.$first_name.' '.$family_name; }
$html = '
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="25">'.$Totaal['stableNumber'].'</td>
<td width="35">'.$Totaal['compNumber'].'</td>
<td width="300">'.$Totaal['complete_name'].' ('.$Totaal['competing_for_country'].')</td>
<td width="150">'.$Totaal['nameGroom'].'</td>';
if($Totaal['caravanNumber'] == '0') {
$html .= ' <td width="50">---</td>';
} else {
$html .= ' <td width="50">'.$Totaal['caravanNumber'].'</td>';
}
$html .= '
<td width="75">+'.$Totaal['cellGroom'].'</td>
</tr>
</table>';
$pdf->writeHTML($html, false, false, true, false, ' ');
}
} else {
$html = 'No records found.';
$pdf->writeHTML($html, true, false, true, false, ' ');
}
}
// ---------------------------------------------------------
//============================================================+
// END OF FILE
//============================================================+
?>
Het script moet 3 soorten gegereren:
1. ?report=Stables&Sort=stable een lijst op 2010Combination.stableNumber volgorde
2. ?report=Stables&Sort=stable een lijst op 2010Combination.compNumber volgorde
3. ?report=Stables&Sort= een lijst op horse.complete_name volgorde met alleen records waarbij 2010Combination.cellGroom leeg is cq niets bevat.
Sorry dat ik het zeggen moet, maar je brengt het probleem op een geheel ander pad.
Het script functioneerd als ik bv $sqlCombiWHERE = "WHERE 2010Combination.cellGroom = ' ' "; er hard in plaats, dus zonder de IF/ELSE