Binnen mijn script gebruik ik deze sql opdracht om alle regels uit een tabel te lezen.

<?php
$sqlCombination = "
	SELECT person.*, horse.*, 2010Combination.* 
	FROM FEIPerson AS person
	INNER 
			JOIN 2010Combination ON person.fei_id = 2010Combination.personFEIid 
	INNER 
			JOIN FEIHorse horse ON horse.fei_id = 2010Combination.horseFEIid 
	GROUP 
			BY 2010Combination.personFEIid
	ORDER 
			BY person.competing_for_country, 2010Combination.compNumber ASC";
?>

En dit is het stukje script dat ik gebruik om o.a. het aantal regels te weten te komen:

<?php
$Result = mysqli_query($dblink, $sqlCombination);
if(!$Result) {
	$html = 'There is een error opening table for listing Combinations; '.mysqli_error();
	$pdf->writeHTML($html, true, false, true, false, ' ');
	}
$numberCombination = mysqli_affected_rows($dblink);
?>

In $numberCombination komt dan het aantal regels te staan, echter deze waarde is foutief.
Kijkend met PHPMYADMIN op de webserver staan in de tabel 3 regels terwijl de waarde in $numberCombination 1 is.
Waar kan dit verschil vandaan komen aangezien ik geen enkele WHERE clausule in de sql opdracht heb staan.

Harry
regel 40 moet dus NA de controle komen of het om hetzelfde land gaat.
Hoi Ivo,

Het zal wel aan mij liggen maar ben het een beetje kwijt.
Is dit nu wat je bedoeldt??

<?php
// Vul hier een rapport specifiek clausule in.
// In dit rapport gaat het om welke combinaties hebben een onderkomen in de caravan nodig
$sqlCombiWHERE = " WHERE 2010Combination.accomGroom = 'YES' ";
// +-----Table header --------------------------------------------------------+
$tbl = '<table cellspacing="0" cellpadding="0" border="1" width="100%">
            <tr>
                <th width="30"> </th>
                <th width="50">Caravan</th>
                <th width="200">Name</th>
                <th width="150">Telefoon</th>
                <th width="145">Horse</th>
                <th width="">Country</th>
            </tr> ';
//        </table>';
$previousCountry = " ";
$report = $_GET['report'];
$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 ASC ";
$sqlCombination = $sqlCombiBASIC . $sqlCombiWHERE . $sqlCombiORDER;

    if(!$Result = mysqli_query($dblink, $sqlCombination)) {
    $html = "There is een error opening table for ". $report. "; ".mysqli_error($dblink)."<br />";
        $html .= "<br />=========================<br />";
}   else {    // database is aanwezig en geopend
$numFemale = $numMale = 0;
$EV_Year = date('Y') . "<br />";
$numberCombinations = mysqli_affected_rows($dblink);
$html .= $EV_Year;
        $html = "<br />=========================<br />";
    /* fetch associative array */
    while ($Row= mysqli_fetch_assoc($Result)) {
/*
$tbl .= '   <tr>
                <td>'.$Row["compNumber"].'</td>
                <td>'.$Row["caravanNumber"].'</td>
                <td>'.$Row["nameGroom"].'</td>
                <td>+'.$Row["cellGroom"].'</td>
                <td>'.$Row["current_name"].'</td>
                <td>'.$Row["competing_for_country"].'</td>
            </tr>';
*/
// -----------------------------------------------------------+
// Verkrijg aantal vrouwelijke verzorgers (Groom)
        if($Row["genderGroom"] == 'Female')  $numFemale++;
//Doe dit ook voor mannelijke groom's
        elseif($Row["genderGroom"] == 'Male')  $numMale++;
// -----------------------------------------------------------+
if($previousCountry!=$Row["competing_for_country"]) {
    $previousCountry=$Row["competing_for_country"];
// add a page
$pdf->AddPage('P', 'A4');
// -----------------------------------------------------------+
$pdf->writeHTML($tbl, true, false, true, false, ' ');
// -----------------------------------------------------------+
}  else { $previousCountry=$Row["competing_for_country"];
$tbl .= '   <tr>
                <td>'.$Row["compNumber"].'</td>
                <td>'.$Row["caravanNumber"].'</td>
                <td>'.$Row["nameGroom"].'</td>
                <td>+'.$Row["cellGroom"].'</td>
                <td>'.$Row["current_name"].'</td>
                <td>'.$Row["competing_for_country"].'</td>
            </tr>';

        }
    }   // end while
            } // end
// Maak een pagina voor totalen
        $sql = "<br />=========================<br />";
        $sql .= "Aantal Groom in caravan: ". $numberCombinations . "<br />";
        $sql .= "Aantal Vrouwlijk: ". $numFemale . "<br />";
        $sql .= "Aantal Manlijk: ". $numMale . "<br />";
        $sql .= "<br />=========================<br />";

// add a page
$pdf->AddPage('P', 'A4');
// -----------------------------------------------------------+
$pdf->writeHTML($sql, true, false, true, false, ' ');
// -----------------------------------------------------------+

?>

Reageren