Log in

View Full Version : Add values of fields



Rob (SA)
05-01-2010, 03:16 PM
Hi Folks,

I am trying to sum the values of numbers in various fields and would like that result to appear in the table.

I would appreciate any reply in this regards

bluewalrus
05-01-2010, 03:55 PM
In a database table or an html table? Can you post your html code or a sample form?

Rob (SA)
05-01-2010, 03:58 PM
Hi,

thanks for the prompt reply.

I have a page that can be veiwed at http://www.gnjgf.co.za/rhresultstest.php

the idea is to sum the numbers right of the word PAR and the result to be posted under the word OUT

Similarly for the next nine values and thier result to appear under the word IN

OUT +IN result is to appear under TOTAL

bluewalrus
05-01-2010, 04:33 PM
Where are those values coming from, are they static? Can you post the code you are using currently to get those values?

Rob (SA)
05-01-2010, 04:40 PM
Hi ,

I hope this helps


<?php

$connect = mysql_connect("localhost", "e*****", "*********") or

die ("Hey loser, check your server connection.");

mysql_select_db("e*****_Members");

$query1="select * from courses";

$result=mysql_query($query1) or die(mysql_error());

?>
<!--------THIS SECTION CHANGES WHAT THE TABLE LOOKS LIKE------------->

<table border=2 width="85%" bordercolor="#D3E2FE" bordercolorlight="#FFFFFF" bordercolordark="#AFBCDB" style="font-size:12px" cellspacing=0>

<caption><b><font style="font-size:14px" color="#00008B" face="Arial">
TOURNAMENT RESULTS</font><b><caption>

<!---------------------------------------------------------------------------------------------------->
<! THIS SECTION ADDS 3 EMPTY LINES IF THERE IS A SPLIT BUT ONLY AFTER SOME RECORDS HAVE BEEN DISPLAYED>
<!---------------------------------------------------------------------------------------------------->

<tr>
<td colspan="22">&nbsp;</td>
</tr>

<tr>

<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">HOLE</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 1</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 2</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 3</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 4</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 5</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 6</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 7</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 8</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 9</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">OUT</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">10</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">11</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">12</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">13</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">14</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">15</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">16</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">17</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">18</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">IN</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">TOTAL</font></b></th>

</tr>

<tr>

<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">PAR</font></b></th>

<?php

while($row=mysql_fetch_array($result)){

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole1'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole2'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole3'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole4'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole5'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole6'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole7'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole8'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole9'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole99'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole10'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole11'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole12'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole13'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole14'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole15'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole16'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole17'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole18'];

echo '</td><td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['parhole999'];

echo "</td></tr>";

if(!isset($counter[$firstNAsAString]))
$counter[$firstNAsAString] = 0;
else
$counter[$firstNAsAString]++;
$last_surname = $row['surname'];

$i++;
echo'</td></tr>';

}

echo "</table>";

?>

bluewalrus
05-01-2010, 05:14 PM
Your table looked off a bit I think I fixed that and the values are totaled too. It may have a few errors my server is unconnectable so I can't test it.


<?php

$connect = mysql_connect("localhost", "e*****", "*********") or

die ("Hey loser, check your server connection.");

mysql_select_db("e*****_Members");

$query1="select * from courses";

$result=mysql_query($query1) or die(mysql_error());

?>
<!--------THIS SECTION CHANGES WHAT THE TABLE LOOKS LIKE------------->

<table border=2 width="85%" bordercolor="#D3E2FE" bordercolorlight="#FFFFFF" bordercolordark="#AFBCDB" style="font-size:12px" cellspacing=0>

<caption><b><font style="font-size:14px" color="#00008B" face="Arial">
TOURNAMENT RESULTS</font><b><caption>


<!---------------------------------------------------------------------------------------------------->
<! THIS SECTION ADDS 3 EMPTY LINES IF THERE IS A SPLIT BUT ONLY AFTER SOME RECORDS HAVE BEEN DISPLAYED>
<!---------------------------------------------------------------------------------------------------->


<tr>
<td colspan="22">&nbsp;</td>
</tr>


<tr>

<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">HOLE</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 1</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 2</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 3</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 4</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 5</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 6</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 7</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 8</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial"> 9</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">OUT</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">10</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">11</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">12</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">13</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">14</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">15</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">16</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">17</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">18</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">IN</font></b></th>
<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">TOTAL</font></b></th>

</tr>

<tr>

<th bgcolor="#D6D6D8"><b><font style="font-size:11px" color="#00008B" face="Arial">PAR</font></b></th>

<?php
$value = 1;
$total = 0;
$front9 = 0;
$back9 = 0;
while($row=mysql_fetch_array($result)){
?>
<tr>
<?php
while ($value < 18 ) {
?>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
<?php
echo $row["parhole$value"];
?>
</td>
<?php
if ($value < 10 ) {
$front9 = $front9 + $row["parhole$value"];
$total = $total + $front9;
} else {
$back9 = $back9 + $row["parhole$value"];
$total = $total + $back9;
}
<?php
if ($value == 9 ) {
?>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
<?php
echo $front9;
?>
</td>
<?php
}
if ($value == 18) {
?>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
<?php
echo $back9;
?>
</td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
<?php
echo total;
?>
</td>
}
$value++;
}
?>
</tr>
<?php
if(!isset($counter[$firstNAsAString])) {
$counter[$firstNAsAString] = 0;
} else {
$counter[$firstNAsAString]++;
$last_surname = $row['surname'];
$i++;
?>
</td></tr>
<?php
}
?>
</table>

Rob (SA)
05-01-2010, 06:04 PM
Hi,

Thanks for your time.

I have posted the changes - however i now get a totally blank screen.

Let me take a look and see where it needs some work

Rob (SA)
05-01-2010, 06:40 PM
I have had a look but to no avail.

Still a blank screen:confused:

bluewalrus
05-02-2010, 06:08 AM
Missed a reopening tag try this one. The blank screen is caused by the error.



<?php
$value = 1;
$total = 0;
$front9 = 0;
$back9 = 0;
while($row=mysql_fetch_array($result)){
?>
<tr>
<?php
while ($value < 19 ) {
?>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
<?php
echo $row["parhole$value"];
?>
</td>
<?php
if ($value < 10 ) {
$front9 = $front9 + $row["parhole$value"];
$total = $total + $front9;
} else {
$back9 = $back9 + $row["parhole$value"];
$total = $total + $back9;
}
<?php
if ($value == 9 ) {
?>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
<?php
echo $front9;
?>
</td>
<?php
}
if ($value == 18) {
?>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
<?php
echo $back9;
?>
</td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">';
<?php
echo total;
?>
</td>
<?php
}
$value++;
}
?>
</tr>
<?php
if(!isset($counter[$firstNAsAString])) {
$counter[$firstNAsAString] = 0;
} else {
$counter[$firstNAsAString]++;
$last_surname = $row['surname'];
$i++;
?>
</td></tr>
<?php
}
?>
</table>

Rob (SA)
05-02-2010, 06:55 AM
Hi,

Thanks agian for taking a look.

If I preview the file prior to publishing this is the result

http://www.gnjgf.co.za/rhresultstest.jpg

bluewalrus
05-02-2010, 02:58 PM
Whats the result?

Rob (SA)
05-02-2010, 06:39 PM
Hi,

Sorry I see the pic isnt working.

The result is better but not working as required.

you can see it at this in the preview but still nothing after publishinghttp://www.gnjgf.co.za/rhresultstest.bmp

bluewalrus
05-03-2010, 03:12 AM
Had 2 more things to correct, let me know if this one works out, sorry servers still not set...



<?php
$value = 1;
$total = 0;
$front9 = 0;
$back9 = 0;
while($row=mysql_fetch_array($result)){
?>
<tr>
<?php
while ($value < 19 ) {
?>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">
<?php
echo $row["parhole$value"];
?>
</td>
<?php
if ($value < 10 ) {
$front9 = $front9 + $row["parhole$value"];
$total = $total + $front9;
} else {
$back9 = $back9 + $row["parhole$value"];
$total = $total + $back9;
}
if ($value == 9 ) {
?>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">
<?php
echo $front9;
?>
</td>
<?php
}
if ($value == 18) {
?>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">
<?php
echo $back9;
?>
</td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:10px" color="#00008B" face="Arial">
<?php
echo total;
?>
</td>
<?php
}
$value++;
}
?>
</tr>
<?php
if(!isset($counter[$firstNAsAString])) {
$counter[$firstNAsAString] = 0;
} else {
$counter[$firstNAsAString]++;
$last_surname = $row['surname'];
$i++;
}
?>
</td></tr>
<?php
}
?>
</table>

Rob (SA)
05-03-2010, 04:31 PM
Hi ,

We are moving in th eright direction.

Not quite there yet.

I am sorry I cannot help that much as my coding experiance is zero.

Can be seen at this link (http://www.gnjgf.co.za/rhresultstest2.php)

I need to get the info on th elower line to appera next to "PAR" and th eword 'total should be a number.

Thanks again for your help - I appreciate it very much

bluewalrus
05-03-2010, 05:15 PM
Okay, try this. This is the whole page...

<style type="text/css">
.cells {
background: #D6D6D8;
font:Arial, Helvetica, sans-serif;
font-size:11px;
color:#00008b;
font-weight:bold;
}
.cellsdata {
background: #D6D6D8;
font:Arial, Helvetica, sans-serif;
font-size:10px;
color:#00008b;
text-align:center;
}
</style>
<?php

$connect = mysql_connect("localhost", "e*****", "*********") or

die ("Hey loser, check your server connection.");

mysql_select_db("e*****_Members");

$query1="select * from courses";

$result=mysql_query($query1) or die(mysql_error());

?>
<!--------THIS SECTION CHANGES WHAT THE TABLE LOOKS LIKE------------->

<table border=2 width="85%" bordercolor="#D3E2FE" bordercolorlight="#FFFFFF" bordercolordark="#AFBCDB" style="font-size:12px" cellspacing=0>

<caption><b><font style="font-size:14px" color="#00008B" face="Arial">
TOURNAMENT RESULTS</font><b><caption>

<!---------------------------------------------------------------------------------------------------->
<! THIS SECTION ADDS 3 EMPTY LINES IF THERE IS A SPLIT BUT ONLY AFTER SOME RECORDS HAVE BEEN DISPLAYED>
<!---------------------------------------------------------------------------------------------------->

<tr>
<td colspan="22">&nbsp;</td>
</tr>

<tr>

<th class="cells">HOLE</th>
<th class="cells"> 1</th>
<th class="cells"> 2</th>
<th class="cells"> 3</th>
<th class="cells"> 4</th>
<th class="cells"> 5</th>
<th class="cells"> 6</th>
<th class="cells"> 7</th>
<th class="cells"> 8</th>
<th class="cells"> 9</th>
<th class="cells">OUT</th>
<th class="cells">10</th>
<th class="cells">11</th>
<th class="cells">12</th>
<th class="cells">13</th>
<th class="cells">14</th>
<th class="cells">15</th>
<th class="cells">16</th>
<th class="cells">17</th>
<th class="cells">18</th>
<th class="cells">IN</th>
<th class="cells">TOTAL</th>
</tr>
<tr>
<th class="cells">PAR</th>
<?php
$value = 1;
$total = 0;
$front9 = 0;
$back9 = 0;
while($row=mysql_fetch_array($result)){
while ($value < 19 ) {
?>
<td class="cellsdata">
<?php
echo $row["parhole$value"];
?>
</td>
<?php
if ($value < 10 ) {
$front9 = $front9 + $row["parhole$value"];
$total = $total + $front9;
} else {
$back9 = $back9 + $row["parhole$value"];
$total = $total + $back9;
}
if ($value == 9 ) {
?>
<td class="cellsdata">
<?php
echo $front9;
?>
</td>
<?php
}
if ($value == 18) {
?>
<td class="cellsdata">
<?php
echo $back9;
?>
</td>
<td class="cellsdata">
<?php
echo $total;
?>
</td>
<?php
}
$value++;
}
?>
</tr>
<?php
if(!isset($counter[$firstNAsAString])) {
$counter[$firstNAsAString] = 0;
} else {
$counter[$firstNAsAString]++;
$last_surname = $row['surname'];
$i++;
}
?>
</td></tr>
<?php
}
?>
</table>

Rob (SA)
05-03-2010, 05:50 PM
Hi,

We are working well at this.

We have a value now excpet that the total should be the reult of the back9 and the front9 which = 72.

It is perhaps because it is taking tha values from all the rows in th edatbase as opposed to just the values in one row.

It is a thought.

Regards
Rob

Rob (SA)
05-03-2010, 05:53 PM
Hi,

To give you an idea of where I am trying to go and make things better for our kids

Here is a link (http://http://uploads.saga.co.za/results_2010/cp2010.htm)

Ultimately I would like to enter data from golf events that will reflect the result in the work you have so kindly done for me.

Regards
Rob

Rob (SA)
05-03-2010, 06:33 PM
Hi,

I have made a change to get the result of 72 in the last field under TOTAL.

I am not sure if this is correct but it has the desired result but may cause a clash elswhere?


<?php
$value = 1;
$total = 0;
$front9 = 0;
$back9 = 0;
while($row=mysql_fetch_array($result)){
while ($value < 19 ) {
?>
<td class="cellsdata">
<?php
echo $row["parhole$value"];
?>
</td>
<?php
if ($value < 10 ) {
$front9 = $front9 + $row["parhole$value"];
$total = $total + $front9;
} else {
$back9 = $back9 + $row["parhole$value"];
$total = $front9 + $back9;
}
if ($value == 9 ) {
?>
<td class="cellsdata">
<?php
echo $front9;
?>
</td>
<?php
}
if ($value == 18) {
?>
<td class="cellsdata">
<?php
echo $back9;
?>
</td>
<td class="cellsdata">
<?php
echo $total;
?>
</td>

bluewalrus
05-03-2010, 06:48 PM
Oh haha yea I see what I did there it was looping through and adding the total each time. That's one way to do it there's another way to do it that would involve more variables but that should work.

Rob (SA)
05-03-2010, 06:51 PM
Hi,

thanks for all your effort and patience

Regards
Rob

Rob (SA)
05-11-2010, 07:53 PM
Hi Chris,

I have loaded another link that perhaps explains the way things should appear when selecting 2,3 or 4.

www.gnjgf.co.za/drawexample.htm

Th eonly difference here is that the forms will populate from the database with names in the columns and handicaps in another.

Handicaps detrmine the order of placing in the table and once the number is selected ie 2,3 or 4 then what you see in the example will be duplicated to represent the players starting on the first 9 and players starting of the second 9.

It would be perfect if we could do the same excercise to incude for time at certain intervals.

I look forward to your reply

Regards
Rob

bluewalrus
05-12-2010, 03:06 AM
So all the users are outputted in tables of 2,3, or 4 and they are grouped by handicaps going from highest to lowest?

So

john, ryan, and tim with handicaps of 0,1, and 2 go in table 1

luke, mark, and matt with handicaps 3,4, and 5 go in table 2

assuming 3 was selected.

Rob (SA)
05-12-2010, 04:46 AM
Hi Chris,

Th eplayers are entered through the tournament entryform www.gnjgf.co.za/entryform.php

The names are then listed by handicap from any value -5 to 36

The list say 120 names long is then divided into two tables (First 9) & (Second 9)

The values are populated from the bottom of the tables starting with the best handicap to the worst 36. Ideally the first nine table is populated first with the best players.

The process of 2,3,4 only determine sthe amount of players per group and has no immediate immplication to handicap.

Currently in www.gnjgf.co.za/stevie/drawtest.php you can see the various tournaments in a handicap listing.

The result of the above will generate what we call a "draw" in golfing terms - basically the order in which players are allocated in a tournament.

So if I select 2 then only two players will be in each group, select 3 then three players will be in a group, etc.

Currently in www.gnjgf.co.za/stevie/drawtest.php you can see the tournaments entered with the handicap listing.

I hope this is of help

Regards
Rob

bluewalrus
05-12-2010, 12:19 PM
Okay so you already have a query to select the players, the handicaps, and arrange them descending by handicap? Can you post the code you're using for that example if it is using the database and isn't static?

Rob (SA)
05-12-2010, 01:58 PM
Hi Chris,

Sure thing I should be home in an hour or so and will post it then.

Thanks for your time

Regards
Rob

Rob (SA)
05-12-2010, 02:58 PM
Hi Chris,

Please find included information you were looking for:


<?php

$connect = mysql_connect("localhost", "e*****_******", "******") or

die ("Hey loser, check your server connection.");

mysql_select_db("e*****_M*****");

$quey1="select * from _Form_Nr_3 ORDER BY `i_wish_to_play` ASC, `my_handicap_is` ASC ";
$result=mysql_query($quey1) or die(mysql_error());


?>
<!------------------------------------------------------------------>
<! THIS SECTION CHANGES WHAT THE TABLE LOOKS LIKE >
<!------------------------------------------------------------------>
<table border=2 width="85%" bordercolor="#D3E2FE" bordercolorlight="#FFFFFF" bordercolordark="#AFBCDB" 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 MYSQL TABLE >
<!------------------------------------------------------------------->
<?php
$counter = array();
$last_i_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="6">&nbsp;</td>
</tr>';
}
//------------------------------------------------------
// THIS SECTION ADDS HEADINGS
//------------------------------------------------------
if ($row['i_wish_to_play'] != $last_wish_to_play) {
echo '<tr>
<td colspan="6" 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>H/CAP</b></font></td>


</tr>';
}

echo '<tr><td bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo '<option value="'.$row['surname'].', '.$row['name'].'">'.$row['surname'].', '.$row['name'].'</option>';

echo '</td><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo $row['my_handicap_is'];

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>';

?>

Rob (SA)
05-12-2010, 03:13 PM
Hi Chris,

Ideally I am going to split the tournaments to seperate pages for easier veiwing.

Regards
ROb