WHERE in SQL opdracht geeft foutmelding.
Code (php)
1
2
3
4
5
6
2
3
4
5
6
if($_GET[sort] == "stable") $sort = "2010Combination.stableNumber";
elseif($_GET[sort] == "combination") $sort = "2010Combination.compNumber";
else $sort = "horse.complete_name";
if($_GET[sort] == "cell") $sqlCombiWHERE = "WHERE 2010Combination.cellGroom = ' ' ";
else $sqlCombiWHERE = " fout ";
elseif($_GET[sort] == "combination") $sort = "2010Combination.compNumber";
else $sort = "horse.complete_name";
if($_GET[sort] == "cell") $sqlCombiWHERE = "WHERE 2010Combination.cellGroom = ' ' ";
else $sqlCombiWHERE = " fout ";
$sort in de eerste drie regels wordt juist gevuld echter $sqlCombiWHERE generrerd een leeg resultaat.
Ik zie geen verschil tussen de eerste if en de tweede, jullie wel?? en waar dan??
Zelf vind ik het overzichtelijker om netjes curly brackets ( { en } ) te gebruiken zoals gebruikelijk bij if statements. Wat enters zijn ook niet verboden.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
if($_GET[sort] == "stable") {
$sort = "2010Combination.stableNumber";
}
elseif($_GET[sort] == "combination")
{
$sort = "2010Combination.compNumber";
}
else {
$sort = "horse.complete_name";
}
if($_GET[sort] == "cell")
{
$sqlCombiWHERE = "WHERE 2010Combination.cellGroom = ' ' ";
}
else {
$sqlCombiWHERE = " test ";
}
?>
if($_GET[sort] == "stable") {
$sort = "2010Combination.stableNumber";
}
elseif($_GET[sort] == "combination")
{
$sort = "2010Combination.compNumber";
}
else {
$sort = "horse.complete_name";
}
if($_GET[sort] == "cell")
{
$sqlCombiWHERE = "WHERE 2010Combination.cellGroom = ' ' ";
}
else {
$sqlCombiWHERE = " test ";
}
?>
Daarnaast controleer je nergens (eerst) op het bestaan van $_GET['sort']?
En tot slot lijkt het erop dat je condities combineert met een sorteervolgorde. En mogelijk heeft ofwel $sort ofwel $sqlCombiWHERE na afloop geen waarde tenzij je deze vantevoren op een waarde initialiseert?
Je zegt dat een bepaalde combinatie een leeg resultaat genereert, maar hoe luidt die uiteindelijke query dan? Dit lijkt mij slechts een deel van alle code waarmee je dynamisch een query opbouwt. Ook weten wij niet hoe de data in de database er verder uitziet.
Het kan best zijn dat jij onder bepaalde condities een bepaald resultaat verwacht, maar als je lang niet alle puzzelstukken aandraagt hoe kunnen wij dan op de vraag "waarom levert dit geen resultaten op" antwoord geven?
de pagina staat onderstaand script. Omdat ik voordat een PDF wordt gemaakt komt TCPDF met een foutmelding.
Toevoeging op 27/07/2017 15:29:46:
Op Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?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
//============================================================+
?>
// 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
//============================================================+
?>
Toevoeging op 27/07/2017 15:29:46:
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.
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.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?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
//============================================================+
?>
// 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.
stap 1: controleer of vereiste user input aanwezig is, en klopt
stap 2: verzamel data uit je bronnen (databases, api's, newsfeeds etc)
stap 3: nu al je variabelen er zijn, kun je aan output denken. bijvoorbeeld een html-pagina, of een pdf document, of misschien wel een gegenereerde afbeelding.
Als er fouten optreden in stap 1 of 2, moet je niet doorgaan naar stap 3. Zeker niet als dat een binaire file is.
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.
Toevoeging op 27/07/2017 15:29:46:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?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
//============================================================+
?>
// 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
//============================================================+
?>
Toevoeging op 27/07/2017 15:29:46:
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.
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.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?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
//============================================================+
?>
// 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.
Toevoeging op 27/07/2017 16:34:59:
Hoi Ivo,
Sorry dat ik het zeggen moet, maar je brengt het probleem op een geheel ander pad.
De vraag was een probleem met een IF ELSE constructie.
Het script functioneerd als ik bv $sqlCombiWHERE = "WHERE 2010Combination.cellGroom = ' ' "; er hard in plaats, dus zonder de IF/ELSE
Hetzelfde geld voor de $sort variabele
Je query bevat een fout, zeg je.
Dan moet je dus nooit al bij je pdf zijn.
Dat je dat wel bent, maakt dat je een debug probleem veroorzaakt.
Maar goed: probeer dan maar je aangemaakte query in je pdf te duwen, en zie daar wat er mis gaat.
--
het stappenplan maakt je leven echter eenvoudiger:
Je zit nu met een probleem midden in een pdf, terwijl als je nog in de afgebakende stap 2 zat, je kon volstaan met een echo $query.
Dat probeer je alsnog te doen,maar dan in de pdf.
Maar je vraag heeft ook helemaal niets te maken met een pdf.
Het gaat om het samenstellen van een query.
Isoleer dat stuk code.
Debug dat.
En als dat niet lukt: plaats dan de vraag met alleen de code van het samenstellen van de query.
Je plaatst nu ellenlange stukken code van meer dan 100 regels.
Dat is voor het beantwootden van de vraag niet handig.
EN ik denk dat je nu zelf ook in je code aan het verzuipen bent.
Maar weer overnieuw gestart