To see what I want, goto : http://www.actionshooting.nl/comp2004/O ... index.html and click "Alle Scores"
Appreciate the help..
Edited this post cause script is a few steps further.
Output is now all matchnames in the headerrow
All competitors and the result for selected category (Klasse) are show in the first column, but only for the match PolderKolder 2005 which is stated in the query.
Question now is, how do make it so that scores for all matches are shown, suppose matchname must come in an array, but have no clue how to do it...
Thanks, been struggling with too long already...
Code: Select all
<?php require_once('../../Connections/Nlprint.php'); ?>
<?php
mysql_select_db($database_Nlprint, $Nlprint);
//Selecting members from ASN
$query_deeln = "SELECT Id, deelnemer.Voornaam, deelnemer.Naam FROM deelnemer WHERE deelnemer.ASNNR >1";
$deeln = mysql_query($query_deeln, $Nlprint) or die(mysql_error());
while ($row = mysql_fetch_assoc($deeln))
{
$ASNm[] = $row['Id'];
}
//Selecting all matches from current year
$sql="SELECT * FROM wedstrijd WHERE(Year(`Datum`) = 2005)ORDER BY datum";
$result=mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
{
$w_naam[] = $row['Naam'];
}
//Select one of four Categories (OKP,SKP,OKR,SKR)
$sqlKlasse = 'SELECT * FROM klasse';
$Kresult = mysql_query($sqlKlasse, $Nlprint) or die(mysql_error());
while ($row = mysql_fetch_assoc($Kresult))
{
$Class[] = $row['Klasse'];
}
if (true === isset($_POST['Search']))
{
$where_clause = '';
// handle search
if (true === isset($_POST['Klasse']))
$k_name = $_POST['Klasse'];
if (0 < strlen($k_name))
{
$where[] = ' Klasse = \'' . $k_name . '\'';
}
if (true === is_array($where))
{
$where_clause = implode(' AND ', $where);
}
}
$rhquery = "SELECT klasse.Klasse,deelnemer.Naam AS Deelnemer,deelnemer.Voornaam AS Voornaam, wedstrijd.Naam AS Wedstrijd, truncate(score.punten ,2) AS Punten ,truncate(score.Tijd, 2) AS Tijd, truncate((score.punten / score.tijd),2) AS HitF FROM deelnemer inner join inschrijving on deelnemer.Id = inschrijving.DeelnemerId inner join wedstrijd on inschrijving.WedstrijdId = wedstrijd.Id inner join klasse on inschrijving.KlasseId = klasse.Id inner join score on inschrijving.Id = score.InschrijvingId inner join score as s2 on inschrijving.Id = s2.InschrijvingId where wedstrijd.Naam = ('PolderKolder 2005')AND klasse.Klasse = ('$k_name') GROUP BY klasse.Klasse, deelnemer.Voornaam, deelnemer.Naam, wedstrijd.Naam, truncate(score.Tijd ,2) HAVING Tijd = min(truncate(s2.Tijd,2)) ORDER BY klasse.Klasse, HitF desc";
$wedstrijdresult = mysql_query($rhquery) or die("Error: " . mysql_error());
$row_count = 2;
// Dropdown
$html_form = '<form action="' . $_SERVER['PHP_SELF'] . '" method="POST">';
$html_form .= '<br /><br ><strong>Selecteer de Klasse <br /></strong>';
$html_form .= '<select name="Klasse">';
$html_form .= '<option selected value="">Klasse</option>';
foreach ($Class as $k_name)
if($k_name == $_POST['Klasse']){
$html_form .= "<option value=\"$k_name\" selected=\"selected\">" . $k_name . "</option>";
}
else{
$html_form .= "<option value=\"$k_name\">" . $k_name . "</option>";
}
$html_form .= '</select> ';
$html_form .= '<input type="submit" name="Search" value="Bekijk" />';
$html_form .= '</form></>';
// build table for outputting match names
$html = '<table border="1">';
$html .= '<tr>';
$Ent=' ';
$html .= '<td border="1" width ="190">'. $Ent .'</td>';
foreach ($w_naam as $w_name)
{
$html .= '<td border="1" width ="190">' . $w_name . '</td>';
}
while ($line = mysql_fetch_array($wedstrijdresult, MYSQL_ASSOC))
{
$row_count = $row_count;
$perc = $line["HitF"];
if (!isset($base)) {
$base = $perc; // set base to the score of this user
}
$Tempperc = ($perc / $base)*100;
$Totperc = round($Tempperc, 3);
$f_name = $line["Voornaam"];
$l_name = $line["Deelnemer"];
$sco = $line["Tijd"];
$html .= '<tr border="1">';
$html .= '<td width="190">'. $f_name ." ". $l_name .'</td>';
$html .= '<td border="1">'. $Totperc .''."%".' </td>';
//$html .= '<td border="1">'. $sco .'</td>';
}
$html .= '</tr>';
$html .= '</table>';
// display results
echo $html_form;
echo $html;
mysql_free_result($deeln);
?>