Hi,
This is what I'm trying to achieve......
An html table on a page which shows results from a series of races with the competitors listed on the x axis and the results per race on the y. Each series has a different number of races so it isn't possible just to hard code the race numbers. the table I'm trying to achieve should look something like
Race Number
Competitors Details 1 2 3 4 Total points
swim faster sinking 5 3 2 4 14
sunk drowned crashed 3 5 5 2 15
I can get the table to create and allocate the correct number of rows for the competitors (do while loop) and show the race numbers columns using a for loop (see code below), what I can't do is get the race by race results to display for each competitor for each race (currently there's another for loop just to create the right number of columns). I'm not sure if it's something to do with the query I'm using to build the table or within the table itself.
//the query....
$serieswanted_seriesresults1 = "-1";
if (isset($_POST['serieschoose'])) {
$serieswanted_seriesresults1 = $_POST['serieschoose'];
}
mysql_select_db($database_sailingdb, $sailingdb);
$query_seriesresults1 = sprintf("SELECT tblresults.race_id AS rid, tblresults.boatcrewid AS bcid, tblresults.reason AS rsn, tblresults.corrected AS crtd, tblresults.seriesid AS sid, SUM(tblresults.points) AS points, tblseries.series AS series, tblseries.races AS races, tblraces.race_number AS rnumb, tblcompetitors.racecrewid AS rcid, tblcompetitors.helm AS hlm, tblcompetitors.crew AS crw, tblcompetitors.boat_id AS btid, tblcompetitors.sailnumber AS snumb, tblm1.name AS helm, tblm2.name AS crew, tblboats.boat_type AS boat FROM tblresults LEFT JOIN tblseries ON tblresults.seriesid = tblseries.seriesid LEFT JOIN tblraces ON tblresults.race_id = tblraces.raceid LEFT JOIN tblcompetitors ON tblcompetitors.racecrewid = tblresults.boatcrewid LEFT JOIN tblmember AS tblm1 ON tblm1.memberid = tblcompetitors.helm LEFT JOIN tblmember AS tblm2 ON tblm2.memberid = tblcompetitors.crew LEFT JOIN tblboats ON tblcompetitors.boat_id = tblboats.boatid WHERE tblresults.seriesid = %s GROUP BY tblresults.boatcrewid", GetSQLValueString($serieswanted_seriesresults1, "int"));
$seriesresults1 = mysql_query($query_seriesresults1, $sailingdb) or die(mysql_error());
$row_seriesresults1 = mysql_fetch_assoc($seriesresults1);
$totalRows_seriesresults1 = mysql_num_rows($seriesresults1);
//the table....
<table border="1" align="center">
<td>Helm</td>
<td>Crew</td>
<td>Boat</td>
<td>Sail Number</td>
<?php for ($b=1;$b<=$i;$b++) { echo "<td>".$b."</td>"; }
//foreach($potentially as $k => $val) { echo "<td>".$k ."</td>"; } ?>
<td>rsn</td>
<td>points</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_seriesresults1['helm']; ?> </td>
<td><?php echo $row_seriesresults1['crew']; ?> </td>
<td><?php echo $row_seriesresults1['boat']; ?> </td>
<td><?php echo $row_seriesresults1['snumb']; ?> </td>
<?php for ($a=1;$a<=$i;$a++) {echo "<td>".$a."</td>"; } ?>
<td><?php echo $row_seriesresults1['rsn']; ?> </td>
<td><?php echo $row_seriesresults1['points']; ?> </td>
</tr>
<?php } while ($row_seriesresults1 = mysql_fetch_assoc($seriesresults1)); ?>
</table>
Anyone got any ideas what should go in
<?php for ($a=1;$a<=$i;$a++) {echo "<td>".$a."</td>"; } ?>
to hopefully get this to work??
Many thanks
Dave