Alright update the blue table with this code (note I didn't test it so there could be some sort of error, back up what you are using now before you change it).
PHP Code:
<?php
$quey1="select * from _Form_Nr_3 ORDER BY `i_wish_to_play` ASC, `surname` ASC ";
$result=mysql_query($quey1) or die(mysql_error());
?>
<!------------------------------------------------------------------>
<! THIS SECTION CHANGES WHAT THE TABLE LOOKS LIKE >
<!------------------------------------------------------------------>
<table border=5 width="85%" style="font-size:11px" cellspacing=0>
<!------------------------------------------------------------------>
<! THIS SECTION CHANGES THE MAIN HEADING >
<!------------------------------------------------------------------>
<caption><b><font style="font-size:16px" color="#00008B" face="Arial">
</font><b><caption>
<!------------------------------------------------------------------->
<! THIS SECTION FETCHES THE INFORMATION FROM THE TABLE >
<!------------------------------------------------------------------->
<?php
$counter = array();
$last_wish_to_play = "";
$firstNAsAString = "";
while($row=mysql_fetch_array($result)){
//----------------------------------------------------------------------------------------------------
// THIS SECTION ADDS 3 EMPTY LINES IF THERE IS A SPLIT BUT ONLY AFTER SOME RECORDS HAVE BEEN DISPLAYED
//----------------------------------------------------------------------------------------------------
if($i > 0 AND $row['i_wish_to_play'] != $last_wish_to_play){
echo '<tr>
<td colspan="3"> </td>
</tr>';
}
//------------------------------------------------------
// THIS SECTION ADDS HEADINGS
//------------------------------------------------------
if ($row['i_wish_to_play'] != $last_wish_to_play) {
echo '<tr>
<td colspan="3" align="center" bgcolor="#FFFFFF"><font style="font-size:11px" color="#00008B" face="Arial"><b>'.$row['i_wish_to_play'].'</b></font></td>
</tr>';
echo '<tr>
<td bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>FULL NAME</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>HANDICAP</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>CELL NUMBER</b></font></td>
</tr>';
}
echo '<tr><td bgcolor="#FFFFFF">';
echo '<option value="'.$row['surname'].', '.$row['name'].'">'.$row['surname'].', '.$row['name'].'</option>';
echo '</td><td align="center" bgcolor="#FFFFFF">';
echo $row['my_handicap_is'];
echo '</td><td align="center" bgcolor="#FFFFFF">';
echo $row['cell_phone'];
if($row['i_wish_to_play'] != $last_wish_to_play)
{
// the first n words to extract
$n = 4;
// extract the words
$words = explode(" ", $row['i_wish_to_play']);
// chop the words array down to the first n elements
$firstN = array_slice($words, 1, $n-1);
// glue the 3 elements back into a spaced sentence
$firstNAsAString = implode(" ", $firstN);
}
if(!isset($counter[$firstNAsAString]))
$counter[$firstNAsAString] = 0;
else
$counter[$firstNAsAString]++;
$last_wish_to_play = $row['i_wish_to_play'];
$i++;
echo '</td></tr>';
}
echo '</table>';
?>
And then replace the code for the red box with this
PHP Code:
<! THIS SECTION FETCHES THE INFORMATION FROM THE TABLE >
<!-------------------------------------------------------------------------------->
<?php
echo '<table>';
foreach($counter as $key => $value)
{
echo '<tr>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:12px" color="#00008B" face="Arial"><b>'.$value.'</b></font></td>
<td colspan="2" align="center" bgcolor="#FFFFFF"><font style="font-size:11px" color="#00008B" face="Arial">'.$key.'</font></td>
</tr>';
}
echo '</table>';
?>