Location: PHPKode > projects > GolfstatsPHP > golfstatsphp_3.0/statsview1.php
<?
include("dbasecon.inc.php");
include("session.inc.php");
include ("header.php");
include ("score_functions.inc.php");

//$player1=$login_id;

//CHECK IF player1 variable has been selected
if (!$player1) {
$player1=$login_id;

}



//get the list of all users
$allusersql="Select distinct(a.userid) as alluserid,a.name as allname,a.surname as allsurname  
						from users_tour a LEFT JOIN games b
						on a.userid=b.userid  
						order by allname ASC";

				$alluserquery=mysql_query($allusersql);
				$alluserrow=mysql_fetch_array($alluserquery);
				
################################################################################
//get user details				
$usersql="Select * from users_tour  
					where userid = '$player1' ";

				$userquery=mysql_query($usersql);
				$userrow=mysql_fetch_array($userquery);
extract($userrow);

//check if user has a game
$gamesql="Select *,date_format(date,'%d/%m/%Y') as real_date from games  
					left join courses 
					ON games.courseid = courses.courseid 			 
					where games.userid = '$player1'
					order by gross_score asc, net_score asc
					LIMIT 5 ";

				$gamequery=mysql_query($gamesql);
				$gamerow=mysql_fetch_array($gamequery);
				$gameexist=mysql_numrows($gamequery);


//count how many rounds 
$nogamesql="Select * from games  
					where userid = '$player1'";

				$nogamequery=mysql_query($nogamesql);
				$nogamerow=mysql_fetch_array($nogamequery);
				$nogameexist=mysql_numrows($nogamequery);





//here we piggy back on the above statement to find the no of chipins
do {
$chipinhole=$nogamerow['chipins'];
$chip_ins=$chip_ins+$chipinhole;

//find the game with the longest drive
$longdrive_game=$nogamerow['longest_drive'];
$longdrive_id=$nogamerow['gameid'];
if (($longdrive_game <> "na") && ($longdrive_game > $longdrive_cur)) {
$longdrive_cur=$longdrive_game;
$longdrive_cur_id=$longdrive_id;
}

} while ($nogamerow=mysql_fetch_array($nogamequery));

				
				
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<? showheader("Overall Statistics"); ?>

<p>

<?
if ($gameexist) {

//get all the stats from ranking table!
$statssql="Select * from ranking  
					where userid = '$player1'";

				$statsquery=mysql_query($statssql);
				$statsrow=mysql_fetch_array($statsquery);
				$statsexist=mysql_numrows($statsquery);

extract($statsrow);


?>
<form method="post" action="<?=$PHP_SELF?>">

<table width="100%">
<tr>
<td class="menu-bg" width=50%><b>Player 1</b><br><select name="player1">

<?

do {


$player1_temp = $alluserrow["alluserid"];

if ($player1_temp==$player1) { $selected = "SELECTED";
} else {
$selected = "";
}


//OK, populate the drop down on the row.
printf("<option value=\"%s\" $selected > %s %s </option>",
$alluserrow["alluserid"], $alluserrow["allname"], $alluserrow["allsurname"]);


} while ($alluserrow=mysql_fetch_array($alluserquery));
echo "</select>&nbsp;&nbsp;";
echo "<input type=\"Submit\" name=\"compare\" value=\"Compare Player\">";
?>





</td>
<td class="menu-bg" width=50%><b>Player 2</b><br><select name="playercomp">
<option value="none"> Select Player </option>
<?
				$alluserquery=mysql_query($allusersql);
				$alluserrow=mysql_fetch_array($alluserquery);
do {


$playercomp_temp = $alluserrow["alluserid"];

if ($playercomp_temp==$playercomp) { $selected = "SELECTED";
} else {
$selected = "";
}


//OK, populate the drop down on the row.
printf("<option value=\"%s\" $selected > %s %s </option>",
$alluserrow["alluserid"], $alluserrow["allname"], $alluserrow["allsurname"]);


} while ($alluserrow=mysql_fetch_array($alluserquery));
echo "</select>&nbsp;&nbsp;";
echo "<input type=\"Submit\" name=\"compare\" value=\"Compare Player\">";
?>

</form>
</td>
</tr>

<tr>
<td width="50%">

<?
//get the mugshot!
$mugshot="mug_"."$player1".".jpg";

?>
<table border=0 width=90%>
<tr><td width=20%>
<img src="images/<?echo $mugshot;?>" border="1">
</td>
<td>
<table border=1>
<tr><td class="menu-bg">Name</td><td><? echo "$name $surname";?></td></tr>
<tr><td class="menu-bg">Age</td><td><? echo "$age";?></td></tr>
<tr><td class="menu-bg">Current Handicap</td><td><? echo "$handicap";?></td></tr>
<tr><td class="menu-bg">Home Club</td><td><? echo "$homeclub";?></td></tr>
<tr><td class="menu-bg">Rounds Played</td><td><? echo "$nogameexist";?></td></tr>
</table>
</td>
</tr>
</table>


<p>
<table border=1>
<tr class="menu-bg">

<td>Top 5 Scores</td><td>Gross</td><td>Net</td><td>Course</td><td>Date</td>
</tr>

<?
$countno=1;
//OK, populate the drop down on the row.
do {

extract($gamerow);
echo "<tr><td align='center' class='menu-bg2'>$countno</td><td>$gross_score</td><td>$net_score</td>";
echo "<td><a href='statscourse2.php?courseid=$courseid&action=view'>$coursename</a></td><td>$real_date</td>"; 


echo "</tr>";

$countno++;																																								 
																																															
} while ($gamerow=mysql_fetch_array($gamequery));
 //endwhile


?>

</table>

<?


$substatssql="Select * from substats where userid='$player1'";

				$substatsquery=mysql_query($substatssql);
				$substatsrow=mysql_fetch_array($substatsquery);
				$substatsexist=mysql_numrows($substatsquery);

				//howmany players				
$noplayers=$substatsexist;
 
extract($substatsrow);

//SEE fields from ranking table
$showfield="Show fields from ranking";
$showfieldquery=mysql_query($showfield);
$showfieldrow=mysql_fetch_array($showfieldquery);				
$showfieldexist=mysql_numrows($showfieldquery);

$fieldcount=0;

do {
$fieldname=$showfieldrow['Field'];

if ($fieldcount>1) {

if (($fieldname == 'puttavg') || ($fieldname == 'puttround') || ($fieldname == 'avgscore') 
|| ($fieldname == 'net_avgscore')|| ($fieldname == 'par3perf')|| ($fieldname == 'par4perf')
|| ($fieldname == 'par5perf')|| ($fieldname == 'net_par3perf')|| ($fieldname == 'net_par4perf')
|| ($fieldname == 'net_par5perf') ) {



$ranksql="Select * from ranking
					ORDER by $fieldname ASC";
} else {
$ranksql="Select * from ranking
					ORDER by $fieldname DESC";

}
				$rankquery=mysql_query($ranksql);
				$rankrow=mysql_fetch_array($rankquery);
				$rankexist=mysql_numrows($rankquery);

//OK NOW to find the ranking!!

$count=1;
$fieldname_rank=$fieldname._rank;
do {

$rank_userid=$rankrow['userid'];
//1.Driving Distance

if ($rank_userid == $player1) {
${$fieldname_rank}=$count;

} //endif userid is loginid
$count++;
} while ($rankrow=mysql_fetch_array($rankquery)); 				


} //endif fieldcount not 0

$fieldcount++;
} while ($showfieldrow=mysql_fetch_array($showfieldquery));




#########Tournament Stats#################
//ok lets get the tourney stats!

################Count tourney stats##############################3
//count how many tournaments
$notourneysql="Select * from games  
					where userid = '$player1' and tournament=1;";

				$notourneyquery=mysql_query($notourneysql);
				$notourneyrow=mysql_fetch_array($notourneyquery);
				$notourneyexist=mysql_numrows($notourneyquery);


//loop through to get the stats

if ($notourneyexist) {
$tourneywins="0";
$tourney3="0";
$tourney5="0";	
$tourneybest=100;
do {
extract($notourneyrow);
if ($tourneyplace==1) {
$tourneywins=$tourneywins+1;
}

if ($tourneyplace<=3) {
$tourney3=$tourney3+1;
}

if ($tourneyplace<=5) {
$tourney5=$tourney5+1;
}

if ($tourneyplace < $tourneybest) {
$tourneybest=$tourneyplace;
}

} while ($notourneyrow=mysql_fetch_array($notourneyquery)); 

//this is to count the averages
$notourneysql="Select sum(tourneyplace) as sumplace,sum(gross_score) as sumgross,sum(net_score) as sumnet from games  
					where userid = '$player1' and tournament=1;";

				$notourneyquery=mysql_query($notourneysql);
				$notourneyrow=mysql_fetch_array($notourneyquery);

extract($notourneyrow);
$tourneyavg=round($sumplace/$notourneyexist,2);
$tourneygrossavg=round($sumgross/$notourneyexist,2);
$tourneynetavg=round($sumnet/$notourneyexist,2);
} else {

$tourneywins="NA";
$tourney3="NA";
$tourney5="NA";
$tourneybest="NA";
$tourneyavg="NA";
$tourneygrossavg="NA";
$tourneynetavg="NA";

} //endif notourney exist

echo "<p>"; 
echo "<table border=1 width=50%>";
echo "<tr class='menu-bg'>";
echo "<td>Tournament Stats</td><td width=30%>&nbsp;</td>";
echo "</tr>";


echo "<tr><td class='menu-bg2'>Tournaments Played</td><td>$notourneyexist</td></tr>";
echo "<tr><td class='menu-bg2'>Wins</td><td>$tourneywins</td></tr>";
echo "<tr><td class='menu-bg2'>Top 3s</td><td>$tourney3</td></tr>";
echo "<tr><td class='menu-bg2'>Top 5s</td><td>$tourney5</td></tr>";
echo "<tr><td class='menu-bg2'>Best Finish</td><td>$tourneybest</td></tr>";
echo "<tr><td class='menu-bg2'>Average Placing</td><td>$tourneyavg</td></tr>";
echo "<tr><td class='menu-bg2'>Average Gross</td><td>$tourneygrossavg</td></tr>";
echo "<tr><td class='menu-bg2'>Average Net</td><td>$tourneynetavg</td></tr>";

echo "</table><p>";

########################End tourney stats#######################


?>
<p>
<table border=1>
<tr class="menu-bg">
<td>Standard Stats</td><td>&nbsp;</td><td>Rank</td><td>Additional</td>
</tr>


<?
echo "<tr><td class='menu-bg2'>Driving Distance</td><td> $ddistance $measureshort</td><td>$ddistance_rank/$rankexist</td>
<td>Tot.Dist:$total_drive_distance Tot.Drvs:$total_drive</td></tr>";
echo "<tr><td class='menu-bg2'>Driving Accuracy Percentage</td><td> $daccuracy %</td><td>$daccuracy_rank/$rankexist</td>
<td>Fwys Hit:$total_fairways_hit Poss.Fwys:$poss_fairways</td></tr>";
echo "<tr><td class='menu-bg2'>
Longest Drive</td><td>$dlongest $measureshort</td><td>$dlongest_rank/$rankexist</td><td>Game:<a href='#' title=\"$longdrive_cur_id\" onClick=\"window.open('players3.php?userid=$userid&gameid=$longdrive_cur_id','$longdrive_cur_id','left=100,top=0,height=730,width=620,scrollbars=yes');return false;\">$longdrive_cur_id</a></td></tr>";
echo "<tr><td class='menu-bg2'>Greens in Regulation Percentage</td><td> $girpct %</td><td>$girpct_rank/$rankexist</td>
<td>Tot.GIR:$total_gir Holes Putted:$total_holes_putt</td></tr>";
echo "<tr><td class='menu-bg2'>Sand Save Percentage</td><td> $sandsavepct %</td><td>$sandsavepct_rank/$rankexist</td>
<td>Tot.Bunkers:$total_bunker Holes Saved:$total_sandsave</td></tr>";
echo "<tr><td class='menu-bg2'>Putting Average</td><td> $puttavg</td><td>$puttavg_rank/$rankexist</td>
<td>Tot.Putts:$total_putts2 Holes Putted:$total_holes_putt</td></tr>";
echo "<tr><td class='menu-bg2'>Putts per round</td><td> $puttround</td><td>$puttround_rank/$rankexist</td>
<td>Avg.Putt:$puttavg Rounds:$nogameexist</td></tr>";
echo "<tr><td class='menu-bg2'>Chip Ins Made</td><td> $chip_ins</td><td>-</td>
<td>-</td></tr>";

echo "</table><p>";


echo "<table border=1>";
echo "<tr class='menu-bg'><td>Scoring</td><td>Gross</td><td>Rank</td><td>Additional</td><td>Net</td><td>Rank</td><td>Additional</td></tr>";
echo "<tr><td class='menu-bg2'>Total Double Eagles</td><td>$totaldoubleeagles</td><td>$totaldoubleeagles_rank/$rankexist</td><td>-</td>
<td>$net_totaldoubleeagles</td><td>$net_totaldoubleeagles_rank/$rankexist</td><td>-</td>";
echo "<tr><td class='menu-bg2'>Total Aces</td><td>$totalholeinone</td><td>$totalholeinone_rank/$rankexist</td><td>-</td>
<td>$net_totalholeinone</td><td>$net_totalholeinone_rank/$rankexist</td><td>-</td>";

echo "<tr><td class='menu-bg2'>Total Eagles</td><td>$totaleagles</td><td>$totaleagles_rank/$rankexist</td><td>-</td>
<td>$net_totaleagles</td><td>$net_totaleagles_rank/$rankexist</td><td>-</td>";
echo "<tr><td class='menu-bg2'>Birdie Avg</td><td>$birdieavg/round</td><td>$birdieavg_rank/$rankexist</td><td>Tot.Birdies:$total_birdies</td>
<td>$net_birdieavg/round</td><td>$net_birdieavg_rank/$rankexist</td><td>Tot.Birdies:$net_total_birdies</td>";
echo "<tr><td class='menu-bg2'>Par Avg</td><td>$paravg/round</td><td>$paravg_rank/$rankexist</td><td>Tot.Pars:$total_par</td>
<td>$net_paravg/round</td><td>$net_paravg_rank/$rankexist</td><td>Tot.Pars:$net_total_par</td>";
echo "<tr><td class='menu-bg2'>Avg Score</td><td>$avgscore/round</td><td>$avgscore_rank/$rankexist</td><td>Tot.Score:$total_gross</td>
<td>$net_avgscore/round</td><td>$net_avgscore_rank/$rankexist</td><td>Tot.Score:$total_net</td>";
echo "<tr><td class='menu-bg2'>Par Breakers</td><td>$parbreakers %</td><td>$parbreakers_rank/$rankexist</td><td>Bird/Eagl:$total_parbreak <br>Tot.Holes:$total_holes</td>
<td>$net_parbreakers %</td><td>$net_parbreakers_rank/$rankexist</td><td>Bird/Eagl:$net_total_parbreak <br>Tot.Holes:$total_holes</td>";
echo "<tr><td class='menu-bg2'>Par 3 Birdies</td><td>$par3birdies %</td><td>$par3birdies_rank/$rankexist</td><td>Par3.Bird:$par3_birdies <br>Tot.Par3:$total_par3</td>
<td>$net_par3birdies %</td><td>$net_par3birdies_rank/$rankexist</td><td>Par3.Bird:$net_par3_birdies <br>Tot.Par3:$total_par3</td>";
echo "<tr><td class='menu-bg2'>Par 4 Birdies</td><td>$par4birdies %</td><td>$par4birdies_rank/$rankexist</td><td>Par4.Bird:$par4_birdies <br>Tot.Par4:$total_par4</td>
<td>$net_par4birdies %</td><td>$net_par4birdies_rank/$rankexist</td><td>Par4.Bird:$net_par4_birdies <br>Tot.Par4:$total_par4</td>";
echo "<tr><td class='menu-bg2'>Par 5 Birdies</td><td>$par5birdies %</td><td>$par5birdies_rank/$rankexist</td><td>Par5.Bird:$par5_birdies <br>Tot.Par5:$total_par5</td>
<td>$net_par5birdies %</td><td>$net_par5birdies_rank/$rankexist</td><td>Par5.Bird:$net_par5_birdies <br>Tot.Par5:$total_par5</td>";
echo "<tr><td class='menu-bg2'>Par 3 Pars</td><td>$par3pars %</td><td>$par3pars_rank/$rankexist</td><td>Par3.Pars:$par3_pars <br>Tot.Par3:$total_par3</td>
<td>$net_par3pars %</td><td>$net_par3pars_rank/$rankexist</td><td>Par3.Pars:$net_par3_pars <br>Tot.Par3:$total_par3</td>";
echo "<tr><td class='menu-bg2'>Par 4 Pars</td><td>$par4pars %</td><td>$par4pars_rank/$rankexist</td><td>Par4.Pars:$par4_pars <br>Tot.Par4:$total_par4</td>
<td>$net_par4pars %</td><td>$net_par4pars_rank/$rankexist</td><td>Par4.Pars:$net_par4_pars <br>Tot.Par4:$total_par4</td>";
echo "<tr><td class='menu-bg2'>Par 5 Pars</td><td>$par5pars %</td><td>$par5pars_rank/$rankexist</td><td>Par5.Pars:$par5_pars <br>Tot.Par5:$total_par5</td>
<td>$net_par5pars %</td><td>$net_par5pars_rank/$rankexist</td><td>Par5.Pars:$net_par5_pars <br>Tot.Par5:$total_par5</td>";
echo "<tr><td class='menu-bg2'>Par 3 Performance</td><td>$par3perf</td><td>$par3perf_rank/$rankexist</td><td>Par3.Score:$total_par3_scores <br>Tot.Par3:$total_par3</td>
<td>$net_par3perf </td><td>$net_par3perf_rank/$rankexist</td><td>Par3.Score:$net_par3_scores <br>Tot.Par3:$total_par3</td>";
echo "<tr><td class='menu-bg2'>Par 4 Performance</td><td>$par4perf</td><td>$par4perf_rank/$rankexist</td><td>Par4.Score:$total_par4_scores <br>Tot.Par4:$total_par4</td>
<td>$net_par4perf </td><td>$net_par4perf_rank/$rankexist</td><td>Par4.Score:$net_par4_scores <br>Tot.Par4:$total_par4</td>";
echo "<tr><td class='menu-bg2'>Par 5 Performance</td><td>$par5perf</td><td>$par5perf_rank/$rankexist</td><td>Par5.Score:$total_par5_scores <br>Tot.Par5:$total_par5</td>
<td>$net_par5perf </td><td>$net_par5perf_rank/$rankexist</td><td>Par5.Score:$net_par5_scores <br>Tot.Par5:$total_par5</td>";
echo "<tr><td class='menu-bg2'>Scrambling</td><td>$scrambling %</td><td>$scrambling_rank/$rankexist</td><td>Scrambled:$scrambled_holes GIR.Miss:$missed_gir</td>
<td>$net_scrambling % </td><td>$net_scrambling_rank/$rankexist</td><td>Scrambled:$net_scrambled_holes GIR.Miss:$missed_gir</td>";

echo "</table>";





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


if ($HTTP_POST_VARS['compare']) {
if ($playercomp == "none") {}
else {

######START THE NEW CAL!#############

//get user details				
$usersql="Select * from users_tour  
					where userid = '$playercomp' ";

				$userquery=mysql_query($usersql);
				$userrow=mysql_fetch_array($userquery);
				$userexist=mysql_numrows($userquery);

extract($userrow);

//check if user has a game
$gamesql="Select *,date_format(date,'%d/%m/%Y') as real_date from games  
					left join courses 
					ON games.courseid = courses.courseid 			 
					where games.userid = '$playercomp'
					order by gross_score asc, net_score asc
					LIMIT 5 ";

				$gamequery=mysql_query($gamesql);
				$gamerow=mysql_fetch_array($gamequery);
				$gameexist=mysql_numrows($gamequery);


//count how many rounds 
$nogamesql="Select * from games  
					where userid = '$playercomp'";

				$nogamequery=mysql_query($nogamesql);
				$nogamerow=mysql_fetch_array($nogamequery);
				$nogameexist=mysql_numrows($nogamequery);
	
//here we piggy back on the above statement to find the no of chipins
do {
$chipinhole=$nogamerow['chipins'];
$chip_ins=$chip_ins+$chipinhole;

//find the game with the longest drive
$longdrive_game=$nogamerow['longest_drive'];
$longdrive_id=$nogamerow['gameid'];
if (($longdrive_game <> "na") && ($longdrive_game > $longdrive_cur)) {
$longdrive_cur=$longdrive_game;
$longdrive_cur_id=$longdrive_id;
}

} while ($nogamerow=mysql_fetch_array($nogamequery));

if ($gameexist) {

//get all the stats from ranking table!
$statssql="Select * from ranking  
					where userid = '$playercomp'";

				$statsquery=mysql_query($statssql);
				$statsrow=mysql_fetch_array($statsquery);
				$statsexist=mysql_numrows($statsquery);

extract($statsrow);

?>
<?
//get the mugshot!
$mugshot="mug_"."$playercomp".".jpg";

?>
<table border=0 width=90%>
<tr><td width=20%>
<img src="images/<?echo $mugshot;?>" border="1">
</td>
<td>
<table border=1>
<tr><td class="menu-bg">Name</td><td><? echo "$name $surname";?></td></tr>
<tr><td class="menu-bg">Age</td><td><? echo "$age";?></td></tr>
<tr><td class="menu-bg">Current Handicap</td><td><? echo "$handicap";?></td></tr>
<tr><td class="menu-bg">Home Club</td><td><? echo "$homeclub";?></td></tr>
<tr><td class="menu-bg">Rounds Played</td><td><? echo "$nogameexist";?></td></tr>
</table>
</td></tr>
</table>
<p>
<table border=1>
<tr class="menu-bg">

<td>Top 5 Scores</td><td>Gross</td><td>Net</td><td>Course</td><td>Date</td>
</tr>

<?
$countno=1;
//OK, populate the drop down on the row.
do {

extract($gamerow);
echo "<tr><td align='center' class='menu-bg2'>$countno</td><td>$gross_score</td><td>$net_score</td>";
echo "<td><a href='statscourse2.php?courseid=$courseid&action=view'>$coursename</a></td><td>$real_date</td>"; 


echo "</tr>";

$countno++;																																								 
																																															
} while ($gamerow=mysql_fetch_array($gamequery));
 //endwhile


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
?>

</table>


<?


$substatssql="Select * from substats where userid='$playercomp'";

				$substatsquery=mysql_query($substatssql);
				$substatsrow=mysql_fetch_array($substatsquery);
				$substatsexist=mysql_numrows($substatsquery);

				//howmany players				
$noplayers=$substatsexist;
 
extract($substatsrow);

//SEE fields from ranking table
$showfield="Show fields from ranking";
$showfieldquery=mysql_query($showfield);
$showfieldrow=mysql_fetch_array($showfieldquery);				
$showfieldexist=mysql_numrows($showfieldquery);

$fieldcount=0;

do {
$fieldname=$showfieldrow['Field'];

if ($fieldcount>1) {

if (($fieldname == 'puttavg') || ($fieldname == 'puttround') || ($fieldname == 'avgscore') 
|| ($fieldname == 'net_avgscore')|| ($fieldname == 'par3perf')|| ($fieldname == 'par4perf')
|| ($fieldname == 'par5perf')|| ($fieldname == 'net_par3perf')|| ($fieldname == 'net_par4perf')
|| ($fieldname == 'net_par5perf') ) {



$ranksql="Select * from ranking
					ORDER by $fieldname ASC";
} else {
$ranksql="Select * from ranking
					ORDER by $fieldname DESC";

}
				$rankquery=mysql_query($ranksql);
				$rankrow=mysql_fetch_array($rankquery);
				$rankexist=mysql_numrows($rankquery);

//OK NOW to find the ranking!!

$count=1;
$fieldname_rank=$fieldname._rank;
do {

$rank_userid=$rankrow['userid'];
//1.Driving Distance

if ($rank_userid == $playercomp) {
${$fieldname_rank}=$count;

} //endif userid is loginid
$count++;
} while ($rankrow=mysql_fetch_array($rankquery)); 				


} //endif fieldcount not 0

$fieldcount++;
} while ($showfieldrow=mysql_fetch_array($showfieldquery));




#########Tournament Stats#################
//ok lets get the tourney stats!

################Count tourney stats##############################3
//count how many tournaments
$notourneysql="Select * from games  
					where userid = '$playercomp' and tournament=1;";

				$notourneyquery=mysql_query($notourneysql);
				$notourneyrow=mysql_fetch_array($notourneyquery);
				$notourneyexist=mysql_numrows($notourneyquery);

$tourneywins="0";
$tourney3="0";
$tourney5="0";	
$tourneybest=100;
//loop through to get the stats
if ($notourneyexist) {
do {
extract($notourneyrow);
if ($tourneyplace==1) {
$tourneywins=$tourneywins+1;
}

if ($tourneyplace<=3) {
$tourney3=$tourney3+1;
}

if ($tourneyplace<=5) {
$tourney5=$tourney5+1;
}

if ($tourneyplace < $tourneybest) {
$tourneybest=$tourneyplace;
}

} while ($notourneyrow=mysql_fetch_array($notourneyquery)); 

//this is to count the averages
$notourneysql="Select sum(tourneyplace) as sumplace,sum(gross_score) as sumgross,sum(net_score) as sumnet from games  
					where userid = '$playercomp' and tournament=1;";

				$notourneyquery=mysql_query($notourneysql);
				$notourneyrow=mysql_fetch_array($notourneyquery);

extract($notourneyrow);
$tourneyavg=round($sumplace/$notourneyexist,2);
$tourneygrossavg=round($sumgross/$notourneyexist,2);
$tourneynetavg=round($sumnet/$notourneyexist,2);
 } else {

$tourneywins="NA";
$tourney3="NA";
$tourney5="NA";
$tourneybest="NA";
$tourneyavg="NA";
$tourneygrossavg="NA";
$tourneynetavg="NA";

} //endif notourney exist
echo "<p>"; 
echo "<table border=1 width=50%>";
echo "<tr class='menu-bg'>";
echo "<td>Tournament Stats</td><td width=30%>&nbsp;</td>";
echo "</tr>";


echo "<tr><td class='menu-bg2'>Tournaments Played</td><td>$notourneyexist</td></tr>";
echo "<tr><td class='menu-bg2'>Wins</td><td>$tourneywins</td></tr>";
echo "<tr><td class='menu-bg2'>Top 3s</td><td>$tourney3</td></tr>";
echo "<tr><td class='menu-bg2'>Top 5s</td><td>$tourney5</td></tr>";
echo "<tr><td class='menu-bg2'>Best Finish</td><td>$tourneybest</td></tr>";
echo "<tr><td class='menu-bg2'>Average Placing</td><td>$tourneyavg</td></tr>";
echo "<tr><td class='menu-bg2'>Average Gross</td><td>$tourneygrossavg</td></tr>";
echo "<tr><td class='menu-bg2'>Average Net</td><td>$tourneynetavg</td></tr>";

echo "</table><p>";

########################End tourney stats#######################



?>
<p>
<table border=1>
<tr class="menu-bg">
<td>Standard Stats</td><td>&nbsp;</td><td>Rank</td><td>Additional</td>
</tr>

<?
echo "<tr><td class='menu-bg2'>Driving Distance</td><td> $ddistance $measureshort</td><td>$ddistance_rank/$rankexist</td>
<td>Tot.Dist:$total_drive_distance Tot.Drvs:$total_drive</td></tr>";
echo "<tr><td class='menu-bg2'>Driving Accuracy Percentage</td><td> $daccuracy %</td><td>$daccuracy_rank/$rankexist</td>
<td>Fwys Hit:$total_fairways_hit Poss.Fwys:$poss_fairways</td></tr>";
echo "<tr><td class='menu-bg2'>Longest Drive</td><td>$dlongest $measureshort</td><td>$dlongest_rank/$rankexist</td><td>Game:<a href='#' title=\"$longdrive_cur_id\" onClick=\"window.open('players3.php?userid=$userid&gameid=$longdrive_cur_id','$longdrive_cur_id','left=100,top=0,height=730,width=620,scrollbars=yes');return false;\">$longdrive_cur_id</a></td></tr>";
echo "<tr><td class='menu-bg2'>Greens in Regulation Percentage</td><td> $girpct %</td><td>$girpct_rank/$rankexist</td>
<td>Tot.GIR:$total_gir Holes Putted:$total_holes_putt</td></tr>";
echo "<tr><td class='menu-bg2'>Sand Save Percentage</td><td> $sandsavepct %</td><td>$sandsavepct_rank/$rankexist</td>
<td>Tot.Bunkers:$total_bunker Holes Saved:$total_sandsave</td></tr>";
echo "<tr><td class='menu-bg2'>Putting Average</td><td> $puttavg</td><td>$puttavg_rank/$rankexist</td>
<td>Tot.Putts:$total_putts2 Holes Putted:$total_holes_putt</td></tr>";
echo "<tr><td class='menu-bg2'>Putts per round</td><td> $puttround</td><td>$puttround_rank/$rankexist</td>
<td>Avg.Putt:$puttavg Rounds:$total_putt_rounds</td></tr>";
echo "<tr><td class='menu-bg2'>Chip Ins Made</td><td> $chip_ins</td><td>-</td>
<td>-</td></tr>";

echo "</table><p>";

echo "<table border=1>";
echo "<tr class='menu-bg'><td>Scoring</td><td>Gross</td><td>Rank</td><td>Additional</td><td>Net</td><td>Rank</td><td>Additional</td></tr>";
echo "<tr><td class='menu-bg2'>Total Double Eagles</td><td>$totaldoubleeagles</td><td>$totaldoubleeagles_rank/$rankexist</td><td>-</td>
<td>$net_totaldoubleeagles</td><td>$net_totaldoubleeagles_rank/$rankexist</td><td>-</td>";
echo "<tr><td class='menu-bg2'>Total Aces</td><td>$totalholeinone</td><td>$totalholeinone_rank/$rankexist</td><td>-</td>
<td>$net_totalholeinone</td><td>$net_totalholeinone_rank/$rankexist</td><td>-</td>";
echo "<tr><td class='menu-bg2'>Total Eagles</td><td>$totaleagles</td><td>$totaleagles_rank/$rankexist</td><td>-</td>
<td>$net_totaleagles</td><td>$net_totaleagles_rank/$rankexist</td><td>-</td>";
echo "<tr><td class='menu-bg2'>Birdie Avg</td><td>$birdieavg/round</td><td>$birdieavg_rank/$rankexist</td><td>Tot.Birdies:$total_birdies</td>
<td>$net_birdieavg/round</td><td>$net_birdieavg_rank/$rankexist</td><td>Tot.Birdies:$net_total_birdies</td>";
echo "<tr><td class='menu-bg2'>Par Avg</td><td>$paravg/round</td><td>$paravg_rank/$rankexist</td><td>Tot.Pars:$total_par</td>
<td>$net_paravg/round</td><td>$net_paravg_rank/$rankexist</td><td>Tot.Pars:$net_total_par</td>";
echo "<tr><td class='menu-bg2'>Avg Score</td><td>$avgscore/round</td><td>$avgscore_rank/$rankexist</td><td>Tot.Score:$total_gross</td>
<td>$net_avgscore/round</td><td>$net_avgscore_rank/$rankexist</td><td>Tot.Score:$total_net</td>";
echo "<tr><td class='menu-bg2'>Par Breakers</td><td>$parbreakers %</td><td>$parbreakers_rank/$rankexist</td><td>Bird/Eagl:$total_parbreak <br>Tot.Holes:$total_holes</td>
<td>$net_parbreakers %</td><td>$net_parbreakers_rank/$rankexist</td><td>Bird/Eagl:$net_total_parbreak <br>Tot.Holes:$total_holes</td>";
echo "<tr><td class='menu-bg2'>Par 3 Birdies</td><td>$par3birdies %</td><td>$par3birdies_rank/$rankexist</td><td>Par3.Bird:$par3_birdies <br>Tot.Par3:$total_par3</td>
<td>$net_par3birdies %</td><td>$net_par3birdies_rank/$rankexist</td><td>Par3.Bird:$net_par3_birdies <br>Tot.Par3:$total_par3</td>";
echo "<tr><td class='menu-bg2'>Par 4 Birdies</td><td>$par4birdies %</td><td>$par4birdies_rank/$rankexist</td><td>Par4.Bird:$par4_birdies <br>Tot.Par4:$total_par4</td>
<td>$net_par4birdies %</td><td>$net_par4birdies_rank/$rankexist</td><td>Par4.Bird:$net_par4_birdies <br>Tot.Par4:$total_par4</td>";
echo "<tr><td class='menu-bg2'>Par 5 Birdies</td><td>$par5birdies %</td><td>$par5birdies_rank/$rankexist</td><td>Par5.Bird:$par5_birdies <br>Tot.Par5:$total_par5</td>
<td>$net_par5birdies %</td><td>$net_par5birdies_rank/$rankexist</td><td>Par5.Bird:$net_par5_birdies <br>Tot.Par5:$total_par5</td>";
echo "<tr><td class='menu-bg2'>Par 3 Pars</td><td>$par3pars %</td><td>$par3pars_rank/$rankexist</td><td>Par3.Pars:$par3_pars <br>Tot.Par3:$total_par3</td>
<td>$net_par3pars %</td><td>$net_par3pars_rank/$rankexist</td><td>Par3.Pars:$net_par3_pars <br>Tot.Par3:$total_par3</td>";
echo "<tr><td class='menu-bg2'>Par 4 Pars</td><td>$par4pars %</td><td>$par4pars_rank/$rankexist</td><td>Par4.Pars:$par4_pars <br>Tot.Par4:$total_par4</td>
<td>$net_par4pars %</td><td>$net_par4pars_rank/$rankexist</td><td>Par4.Pars:$net_par4_pars <br>Tot.Par4:$total_par4</td>";
echo "<tr><td class='menu-bg2'>Par 5 Pars</td><td>$par5pars %</td><td>$par5pars_rank/$rankexist</td><td>Par5.Pars:$par5_pars <br>Tot.Par5:$total_par5</td>
<td>$net_par5pars %</td><td>$net_par5pars_rank/$rankexist</td><td>Par5.Pars:$net_par5_pars <br>Tot.Par5:$total_par5</td>";
echo "<tr><td class='menu-bg2'>Par 3 Performance</td><td>$par3perf</td><td>$par3perf_rank/$rankexist</td><td>Par3.Score:$total_par3_scores <br>Tot.Par3:$total_par3</td>
<td>$net_par3perf </td><td>$net_par3perf_rank/$rankexist</td><td>Par3.Score:$net_par3_scores <br>Tot.Par3:$total_par3</td>";
echo "<tr><td class='menu-bg2'>Par 4 Performance</td><td>$par4perf</td><td>$par4perf_rank/$rankexist</td><td>Par4.Score:$total_par4_scores <br>Tot.Par4:$total_par4</td>
<td>$net_par4perf </td><td>$net_par4perf_rank/$rankexist</td><td>Par4.Score:$net_par4_scores <br>Tot.Par4:$total_par4</td>";
echo "<tr><td class='menu-bg2'>Par 5 Performance</td><td>$par5perf</td><td>$par5perf_rank/$rankexist</td><td>Par5.Score:$total_par5_scores <br>Tot.Par5:$total_par5</td>
<td>$net_par5perf </td><td>$net_par5perf_rank/$rankexist</td><td>Par5.Score:$net_par5_scores <br>Tot.Par5:$total_par5</td>";
echo "<tr><td class='menu-bg2'>Scrambling</td><td>$scrambling %</td><td>$scrambling_rank/$rankexist</td><td>Scrambled:$scrambled_holes GIR.Miss:$missed_gir</td>
<td>$net_scrambling % </td><td>$net_scrambling_rank/$rankexist</td><td>Scrambled:$net_scrambled_holes GIR.Miss:$missed_gir</td>";

echo "</table>";





} //endif gameexist				




}//endif $compare==none


} //endif HTTP_POSTVARS['compare']


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



} else {

echo "You don't have any scorecards yet. Please enter score cards <a href='statsmain.php'>here</a>.";


} //endif gameexist

?>


	 
<? showfooter(); ?>
Return current item: GolfstatsPHP