Complicated table layout
Posted: Mon Dec 19, 2005 11:47 am
Hi,
I want to display a table with different values form different tables.
In the header row there should come a value form the table 'wedstrijd'
In the first column names of the participants of this match
rows after their names a value which is calculated per match
All this based on a selection (allready in script)
Something like this:
-- |Match1| Matchname2|Matchname3
Contester1 | score| score |score
Contester2 | score | score |score
Who can help with this ??
I have so far :
Select box, names of the matches (displayed vertically in a column, want to display them horizontically)
I another script I use the following query for calculating the score result for the match:
Script:
I want to display a table with different values form different tables.
In the header row there should come a value form the table 'wedstrijd'
In the first column names of the participants of this match
rows after their names a value which is calculated per match
All this based on a selection (allready in script)
Something like this:
-- |Match1| Matchname2|Matchname3
Contester1 | score| score |score
Contester2 | score | score |score
Who can help with this ??
I have so far :
Select box, names of the matches (displayed vertically in a column, want to display them horizontically)
I another script I use the following query for calculating the score result for the match:
Code: Select all
"SELECT klasse.Klasse,deelnemer.Naam AS Deelnemer,deelnemer.Voornaam AS Voornaam, deelnemer.Vereniging AS Vereniging, deelnemer.URL AS URL, 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 = ('$w_naam')AND klasse.Klasse = ('$g_name') GROUP BY klasse.Klasse, deelnemer.Voornaam, deelnemer.Naam, deelnemer.Vereniging , deelnemer.URL, wedstrijd.Naam, truncate(score.Tijd ,2) HAVING Tijd = min(truncate(s2.Tijd,2)) ORDER BY klasse.Klasse, HitF desc";Code: Select all
<style type="text/css">
<!--
body {
background-image: url(../../images/bg_grad.jpg);
margin-top: 0px;
}
-->
</style><?php require_once('../../Connections/ASN.php'); ?>
<?php
mysql_select_db($database_ASN, $ASN);
$sql="SELECT * FROM wedstrijd WHERE(Year(`Datum`) = 2005)ORDER BY datum";
$result=mysql_query($sql);
$sqlKlasse = 'SELECT * FROM klasse';
$Kresult = mysql_query($sqlKlasse, $ASN) or die(mysql_error());
while ($row = mysql_fetch_assoc($Kresult))
{
$Class[] = $row['Klasse'];
}
// 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)
{
$html_form .= '<option>' . $k_name . '</option>';
}
$html_form .= '</select> ';
// Search button
$html_form .= '<input type="submit" name="Search" value="Bekijk" />';
$html_form .= '</form></>';
// build table for outputting news items
$html = '<table border="1">';
// Create table header row (Here should display all `wedstrijd`.`Naam` fields)
$html .= '<tr>';
$html .= '<td>Wedstrijd</td>';
//$html .= '<td>Plaats</td>';
$html .= '<td>Datum</td>';
$html .= '</tr>';
while ($row = mysql_fetch_assoc($result))
{
// print 1st line of data
$html .= '<tr>';
$html .= '<td>'. $row['Naam'] . '</td>';
//$html .= '<td>'. $row['Datum'] . '</td>';
$html .= '</tr>';
// print 2nd line of data
$html .= '<tr>';
$html .= '<td colspan="2">'. $row['Plaats'] . '</td>';
$html .= '</tr>';
}
// close table tag
$html .= '</table>';
// display resutls
echo $html_form;
echo $html;
?>