virker ikke ved limit over 2
HejFølgende kode virker ikke hvis jeg sætter limit til et tal større end 2.
LIMIT er sat til 3 nedenfor.
Hvorfor virker det kun ved LIMIT mindre end 3
<?php
defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );
include $_SERVER['DOCUMENT_ROOT'].'/php/electric.php';
include $_SERVER['DOCUMENT_ROOT'].'/php/course.php';
include $_SERVER['DOCUMENT_ROOT'].'/php/counter.php';
include $_SERVER['DOCUMENT_ROOT'].'/php/elite_statistik_functions.php';
// load database with the player information
$database_spiller = &JFactory::getDBO();
$query_spiller = 'SELECT b.*
FROM #__elite_spiller AS b
ORDER BY b.navn ASC LIMIT 3 ';
$database_spiller->setQuery($query_spiller);
$posts_spiller = $database_spiller->loadObjectList();
// go through each element of the database
foreach ($posts_spiller as $post_spiller) {
// load database with results
$database = &JFactory::getDBO();
$query = 'SELECT a.*
FROM #__elite_statistik AS a
WHERE a.spillerid='.$post_spiller->medlemsnr.'
ORDER BY (a.score_hul1+a.score_hul2+a.score_hul3+a.score_hul4+a.score_hul5+a.score_hul6+a.score_hul7+a.score_hul8+a.score_hul9+a.score_hul10+a.score_hul11+a.score_hul12+a.score_hul13+a.score_hul14+a.score_hul15+a.score_hul16+a.score_hul17+a.score_hul18) ASC';
$database->setQuery($query);
$posts = $database->loadObjectList();
// global variables
$imgWidth = 10;
$spiller_counter = 0;
$electric[] = array();
// go through each element of the database for that player
foreach ($posts as $post) {
$counter = new Counter;
$electric[$spiller_counter] = new Electric;
// load database with the match information
$database_match = &JFactory::getDBO();
$query_match = 'SELECT b.*
FROM #__elite_match AS b
WHERE b.id='.$post->matchId.'
ORDER BY b.id DESC ';
$database_match->setQuery($query_match);
$posts_match = $database_match->loadObjectList();
// look up information from the match
foreach ($posts_match as $post_match) {
// load database with the course information
$database_bane = &JFactory::getDBO();
$query_bane = 'SELECT b.*
FROM #__elite_bane AS b
WHERE b.id='.$post_match->baneId.'
ORDER BY b.id DESC ';
$database_bane->setQuery($query_bane);
$posts_bane = $database_bane->loadObjectList();
// look up information from the course
foreach ($posts_bane as $post_bane) {
$length_ud=
$post_bane->length_hul1+
$post_bane->length_hul2+
$post_bane->length_hul3+
$post_bane->length_hul4+
$post_bane->length_hul5+
$post_bane->length_hul6+
$post_bane->length_hul7+
$post_bane->length_hul8+
$post_bane->length_hul9;
$length_ind=
$post_bane->length_hul10+
$post_bane->length_hul11+
$post_bane->length_hul12+
$post_bane->length_hul13+
$post_bane->length_hul14+
$post_bane->length_hul15+
$post_bane->length_hul16+
$post_bane->length_hul17+
$post_bane->length_hul18;
$length_tot=$length_ud+$length_ind;
$counter->setPar($post_bane->par_hul1);
$counter->setPar($post_bane->par_hul2);
$counter->setPar($post_bane->par_hul3);
$counter->setPar($post_bane->par_hul4);
$counter->setPar($post_bane->par_hul5);
$counter->setPar($post_bane->par_hul6);
$counter->setPar($post_bane->par_hul7);
$counter->setPar($post_bane->par_hul8);
$counter->setPar($post_bane->par_hul9);
$counter->setPar($post_bane->par_hul10);
$counter->setPar($post_bane->par_hul11);
$counter->setPar($post_bane->par_hul12);
$counter->setPar($post_bane->par_hul13);
$counter->setPar($post_bane->par_hul14);
$counter->setPar($post_bane->par_hul15);
$counter->setPar($post_bane->par_hul16);
$counter->setPar($post_bane->par_hul17);
$counter->setPar($post_bane->par_hul18);
$arrPar=$counter->getArrPar();
$par_ud=0;
$par_ind=0;
$electric[$spiller_counter]->setScore($post->score_hul1);
$electric[$spiller_counter]->setScore($post->score_hul2);
$electric[$spiller_counter]->setScore($post->score_hul3);
$electric[$spiller_counter]->setScore($post->score_hul4);
$electric[$spiller_counter]->setScore($post->score_hul5);
$electric[$spiller_counter]->setScore($post->score_hul6);
$electric[$spiller_counter]->setScore($post->score_hul7);
$electric[$spiller_counter]->setScore($post->score_hul8);
$electric[$spiller_counter]->setScore($post->score_hul9);
$electric[$spiller_counter]->setScore($post->score_hul10);
$electric[$spiller_counter]->setScore($post->score_hul11);
$electric[$spiller_counter]->setScore($post->score_hul12);
$electric[$spiller_counter]->setScore($post->score_hul13);
$electric[$spiller_counter]->setScore($post->score_hul14);
$electric[$spiller_counter]->setScore($post->score_hul15);
$electric[$spiller_counter]->setScore($post->score_hul16);
$electric[$spiller_counter]->setScore($post->score_hul17);
$electric[$spiller_counter]->setScore($post->score_hul18);
$counter->setScore($post->score_hul1);
$counter->setScore($post->score_hul2);
$counter->setScore($post->score_hul3);
$counter->setScore($post->score_hul4);
$counter->setScore($post->score_hul5);
$counter->setScore($post->score_hul6);
$counter->setScore($post->score_hul7);
$counter->setScore($post->score_hul8);
$counter->setScore($post->score_hul9);
$counter->setScore($post->score_hul10);
$counter->setScore($post->score_hul11);
$counter->setScore($post->score_hul12);
$counter->setScore($post->score_hul13);
$counter->setScore($post->score_hul14);
$counter->setScore($post->score_hul15);
$counter->setScore($post->score_hul16);
$counter->setScore($post->score_hul17);
$counter->setScore($post->score_hul18);
$arrScore=$counter->getArrScore();
$score_ud=0;
$score_ind=0;
$counter->setPutt($post->putt_hul1);
$counter->setPutt($post->putt_hul2);
$counter->setPutt($post->putt_hul3);
$counter->setPutt($post->putt_hul4);
$counter->setPutt($post->putt_hul5);
$counter->setPutt($post->putt_hul6);
$counter->setPutt($post->putt_hul7);
$counter->setPutt($post->putt_hul8);
$counter->setPutt($post->putt_hul9);
$counter->setPutt($post->putt_hul10);
$counter->setPutt($post->putt_hul11);
$counter->setPutt($post->putt_hul12);
$counter->setPutt($post->putt_hul13);
$counter->setPutt($post->putt_hul14);
$counter->setPutt($post->putt_hul15);
$counter->setPutt($post->putt_hul16);
$counter->setPutt($post->putt_hul17);
$counter->setPutt($post->putt_hul18);
$arrPutt=$counter->getArrPutt();
$putt_ud=0;
$putt_ind=0;
$counter->setGIR($post->score_hul1,$post_bane->par_hul1,$post->putt_hul1);
$counter->setGIR($post->score_hul2,$post_bane->par_hul2,$post->putt_hul2);
$counter->setGIR($post->score_hul3,$post_bane->par_hul3,$post->putt_hul3);
$counter->setGIR($post->score_hul4,$post_bane->par_hul4,$post->putt_hul4);
$counter->setGIR($post->score_hul5,$post_bane->par_hul5,$post->putt_hul5);
$counter->setGIR($post->score_hul6,$post_bane->par_hul6,$post->putt_hul6);
$counter->setGIR($post->score_hul7,$post_bane->par_hul7,$post->putt_hul7);
$counter->setGIR($post->score_hul8,$post_bane->par_hul8,$post->putt_hul8);
$counter->setGIR($post->score_hul9,$post_bane->par_hul9,$post->putt_hul9);
$counter->setGIR($post->score_hul10,$post_bane->par_hul10,$post->putt_hul10);
$counter->setGIR($post->score_hul11,$post_bane->par_hul11,$post->putt_hul11);
$counter->setGIR($post->score_hul12,$post_bane->par_hul12,$post->putt_hul12);
$counter->setGIR($post->score_hul13,$post_bane->par_hul13,$post->putt_hul13);
$counter->setGIR($post->score_hul14,$post_bane->par_hul14,$post->putt_hul14);
$counter->setGIR($post->score_hul15,$post_bane->par_hul15,$post->putt_hul15);
$counter->setGIR($post->score_hul16,$post_bane->par_hul16,$post->putt_hul16);
$counter->setGIR($post->score_hul17,$post_bane->par_hul17,$post->putt_hul17);
$counter->setGIR($post->score_hul18,$post_bane->par_hul18,$post->putt_hul18);
$arrGIR=$counter->getArrGIR();
$udGIR=0;
$indGIR=0;
$counter->setFW($post->fw_hul1,$post_bane->par_hul1);
$counter->setFW($post->fw_hul2,$post_bane->par_hul2);
$counter->setFW($post->fw_hul3,$post_bane->par_hul3);
$counter->setFW($post->fw_hul4,$post_bane->par_hul4);
$counter->setFW($post->fw_hul5,$post_bane->par_hul5);
$counter->setFW($post->fw_hul6,$post_bane->par_hul6);
$counter->setFW($post->fw_hul7,$post_bane->par_hul7);
$counter->setFW($post->fw_hul8,$post_bane->par_hul8);
$counter->setFW($post->fw_hul9,$post_bane->par_hul9);
$counter->setFW($post->fw_hul10,$post_bane->par_hul10);
$counter->setFW($post->fw_hul11,$post_bane->par_hul11);
$counter->setFW($post->fw_hul12,$post_bane->par_hul12);
$counter->setFW($post->fw_hul13,$post_bane->par_hul13);
$counter->setFW($post->fw_hul14,$post_bane->par_hul14);
$counter->setFW($post->fw_hul15,$post_bane->par_hul15);
$counter->setFW($post->fw_hul16,$post_bane->par_hul16);
$counter->setFW($post->fw_hul17,$post_bane->par_hul17);
$counter->setFW($post->fw_hul18,$post_bane->par_hul18);
$arrFW=$counter->getArrFW();
$fw_ud=0;
$fw_ind=0;
$counter->setScramble($post->score_hul1,$post_bane->par_hul1,$post->putt_hul1);
$counter->setScramble($post->score_hul2,$post_bane->par_hul2,$post->putt_hul2);
$counter->setScramble($post->score_hul3,$post_bane->par_hul3,$post->putt_hul3);
$counter->setScramble($post->score_hul4,$post_bane->par_hul4,$post->putt_hul4);
$counter->setScramble($post->score_hul5,$post_bane->par_hul5,$post->putt_hul5);
$counter->setScramble($post->score_hul6,$post_bane->par_hul6,$post->putt_hul6);
$counter->setScramble($post->score_hul7,$post_bane->par_hul7,$post->putt_hul7);
$counter->setScramble($post->score_hul8,$post_bane->par_hul8,$post->putt_hul8);
$counter->setScramble($post->score_hul9,$post_bane->par_hul9,$post->putt_hul9);
$counter->setScramble($post->score_hul10,$post_bane->par_hul10,$post->putt_hul10);
$counter->setScramble($post->score_hul11,$post_bane->par_hul11,$post->putt_hul11);
$counter->setScramble($post->score_hul12,$post_bane->par_hul12,$post->putt_hul12);
$counter->setScramble($post->score_hul13,$post_bane->par_hul13,$post->putt_hul13);
$counter->setScramble($post->score_hul14,$post_bane->par_hul14,$post->putt_hul14);
$counter->setScramble($post->score_hul15,$post_bane->par_hul15,$post->putt_hul15);
$counter->setScramble($post->score_hul16,$post_bane->par_hul16,$post->putt_hul16);
$counter->setScramble($post->score_hul17,$post_bane->par_hul17,$post->putt_hul17);
$counter->setScramble($post->score_hul18,$post_bane->par_hul18,$post->putt_hul18);
$arrScramble = $counter->getArrScramble();
$scramble_ud = 0;
$scramble_ind = 0;
for ($i = 0; $i < 18; $i++) {
$counter->setScoreToPar($arrScore[$i],$arrPar[$i]);
}
// calculate statistics
$counter->calcPutt();
$counter->calcScoreToPar();
}
$spiller_counter++;
}
}
// ELECTRIC----------------------------------------------------------------------------------------------------------------------------------------
// load database with the course information
$database_bane = &JFactory::getDBO();
$query_bane = 'SELECT b.*
FROM #__elite_bane AS b
WHERE b.id='.$post->baneId.'
ORDER BY b.id DESC ';
$database_bane->setQuery($query_bane);
$posts_bane = $database_bane->loadObjectList();
$course = new Course;
foreach ($posts_bane as $post_bane) {
$course->setPar($post_bane->par_hul1);
$course->setPar($post_bane->par_hul2);
$course->setPar($post_bane->par_hul3);
$course->setPar($post_bane->par_hul4);
$course->setPar($post_bane->par_hul5);
$course->setPar($post_bane->par_hul6);
$course->setPar($post_bane->par_hul7);
$course->setPar($post_bane->par_hul8);
$course->setPar($post_bane->par_hul9);
$course->setPar($post_bane->par_hul10);
$course->setPar($post_bane->par_hul11);
$course->setPar($post_bane->par_hul12);
$course->setPar($post_bane->par_hul13);
$course->setPar($post_bane->par_hul14);
$course->setPar($post_bane->par_hul15);
$course->setPar($post_bane->par_hul16);
$course->setPar($post_bane->par_hul17);
$course->setPar($post_bane->par_hul18);
$arrPar = $course->getArrPar();
}
$arrScoreElectric = $electric[0]->getArrScore();
$score_ud = 0;
$score_ind = 0;
$par_ud = 0;
$par_ind = 0;
$score_gns_ud = 0;
$score_gns_ind = 0;
for ($i = 0; $i < count($electric); $i++) {
$arrScore10 = $electric[$i]->getArrScore();
for ($h = 0; $h < 18; $h++) {
if ($arrScoreElectric[$h]>$arrScore10[$h]){ // if electric is higher than this
$arrScoreElectric[$h]=$arrScore10[$h]; // then save this as new electric
}
}
}
// make an array containing all holes
$arrScoreNew[] = array();
for ($h = 0; $h < 18; $h++) {
$arrScoreNew[$h] = array();
}
// each hole contain an array with scores on the hole
for ($i = 0; $i < count($electric); $i++) {
$arrScore10 = $electric[$i]->getArrScore();
for ($h = 0; $h < 18; $h++) {
$arrScoreNew[$h][$i] = $arrScore10[$h];
}
}
echo "<table width='100%' align='center' border='0' cellspacing='0' cellpadding='0'>";
echo "<tr>";
echo "<td valign='top' width='100%'>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";
echo "<tr class='row0'>";
echo "<td colspan='2'><strong>STATISTIK</strong></td>";
echo "</tr>";
echo "<tr class='row2'>";
echo "<td ><strong>". getSpiller($post->spillerId) ."</strong></td>";
echo "<td align='right' ></td>";
echo "</tr>";
echo "</table>";
echo "<hr />";
echo "</td>";
echo "</tr>";
echo "</table>";
// calculate average score
$arrScoreGns[] = array();
$arrScoreGnsToPar[] = array();
$arrScoreGnsToParRang[] = array();
for ($h = 0; $h < 18; $h++) {
$arrScoreGns[$h] = array_sum($arrScoreNew[$h])/count($electric);
$arrScoreGnsToPar[$h] = $arrScoreGns[$h]-$arrPar[$h];
}
// calculate round gns
$roundTotal=0;
for ($h = 0; $h < 18; $h++) {
$roundTotal += array_sum($arrScoreNew[$h]);
$roundTotal;
}
$roundGns=$roundTotal/count($electric);
// sort for rangering
natsort($arrScoreGnsToPar);
//print_r($arrScoreGnsToPar);
$rang=0;
foreach ($arrScoreGnsToPar as $key => $val) {
$arrScoreGnsToParRang[$key] = $rang;
$rang++;
}
echo "<table width='100%' align='center' border='0' cellspacing='0' cellpadding='0'>";
echo "<tr>";
echo "<td valign='top' width='100%'>";
echo "<table class='formlist' style='width: 100%; padding: 0px;' border='0' cellpadding='0' cellspacing='1'>";
echo "<tr class='row0'>";
echo "<td align='center' width='43'><strong>Hul</strong></td>";
echo "<td align='center' width='43'><strong>Par</strong></td>";
echo "<td align='center' width='43'><strong>Best</strong></td>";
echo "<td align='center' width='43'><strong>Gns</strong></td>";
echo "<td align='center' width='43'><strong>Gns to par</strong></td>";
echo "<td align='center' width='43'><strong>Rang</strong></td>";
echo "<td align='center' width='43'><strong>Eagle</strong></td>";
echo "<td align='center' width='43'><strong>Birdie</strong></td>";
echo "<td align='center' width='43'><strong>Par</strong></td>";
echo "<td align='center' width='43'><strong>Bogey</strong></td>";
echo "<td align='center' width='43'><strong>DBogey</strong></td>";
echo "</tr>";
// to count total number of birdies, pars etc
$arrScoreToPar[] = array();
for ($h = 0; $h < 5; $h++) {
$arrScoreToPar[$h] = array();
}
for ($i = 0; $i < 18; $i++) {
$count_eagle=0;
$count_birdie=0;
$count_par=0;
$count_bogey=0;
$count_dbogey=0;
for ($h = 0; $h < count($electric); $h++) {
if($arrScoreNew[$i][$h]<($arrPar[$i])-1){
$count_eagle++;
$arrScoreToPar[$i][0] = $count_eagle;
} elseif ($arrScoreNew[$i][$h] == ($arrPar[$i])-1){
$count_birdie++;
$arrScoreToPar[$i][1] = $count_birdie;
} elseif ($arrScoreNew[$i][$h] == $arrPar[$i]){
$count_par++;
$arrScoreToPar[$i][2] = $count_par;
} elseif ($arrScoreNew[$i][$h] == ($arrPar[$i])+1){
$count_bogey++;
$arrScoreToPar[$i][3] = $count_bogey;
} elseif ($arrScoreNew[$i][$h] > ($arrPar[$i])+1){
$count_dbogey++;
$arrScoreToPar[$i][4] = $count_dbogey;
} else {
}
}
$score_ud += $arrScoreElectric[$i];
$par_ud += $arrPar[$i];
$score_gns_ud += $arrScoreGns[$i];
}
$score_tot = $score_ud+$score_ind;
$par_tot = $par_ud+$par_ind;
//$score_gns_tot = $score_gns_ud+$score_gns_ind;
foreach($arrScoreToPar as $array)
{
$total_eagle += $array[0];
$total_birdie += $array[1];
$total_par += $array[2];
$total_bogey += $array[3];
$total_dbogey += $array[4];
}
echo "<tr class='row2'>";
echo "<td style='text-align: center;' align='center'><strong>TOT</strong></td>";
echo "<td style='text-align: center;' align='center'>". $par_tot ."</td>";
echo "<td style='text-align: center;' align='center'>". $score_tot ."</td>";
echo "<td style='text-align: center;' align='center'>". number_format($roundGns,1) ."</td>";
echo "<td style='text-align: center;' align='center'>". number_format($roundGns-$par_tot,1) ."</td>";
echo "<td style='text-align: center;' align='center'></td>";
echo "<td style='text-align: center;' align='center'>". $total_eagle ."</td>";
echo "<td style='text-align: center;' align='center'>". $total_birdie ."</td>";
echo "<td style='text-align: center;' align='center'>". $total_par ."</td>";
echo "<td style='text-align: center;' align='center'>". $total_bogey ."</td>";
echo "<td style='text-align: center;' align='center'>". $total_dbogey ."</td>";
echo "</tr>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "</table>";
}
?>