Location: PHPKode > projects > GolfstatsPHP > golfstatsphp_3.0/substats.inc.php
<?
//initialise vars
//main vars
$driving_distance=0;
$pct_fairways_hit=0;
$pct_sandsaves=0; 
//$longest_drive1=0; 
$pct_gir=0; 
$avg_putt=0; 
$putts_per_round=0; 
//$total_eagles=0; 
$avg_birdie=0; 
$avg_par=0; 
$avg_gross=0; 
$pct_parbreak=0; 
$par3_birdie_pct=0; 
$par4_birdie_pct=0; 
$par5_birdie_pct=0; 
$par3_par_pct=0; 
$par4_par_pct=0; 
$par5_par_pct=0; 
$par3_avg_score=0; 
$par4_avg_score=0; 
$par5_avg_score=0; 
$scrambling_pct=0;
//$net_total_eagles=0; 
$net_avg_birdie=0; 
$net_avg_par=0; 
$avg_net=0; 
$net_pct_parbreak=0; 
$net_par3_birdie_pct=0; 
$net_par4_birdie_pct=0; 
$net_par5_birdie_pct=0; 
$net_par3_par_pct=0; 
$net_par4_par_pct=0; 
$net_par5_par_pct=0; 
$net_par3_avg_score=0; 
$net_par4_avg_score=0; 
$net_par5_avg_score=0;
$net_scrambling_pct=0; 
$total_mny=0; 
$total_pts=0;


//checks
//check to make sure if there's no total par3s there's no 0 division!
if ($total_par3<1) {$total_par3=1;}

//check to make sure if there's no total par4s there's no 0 division!
if ($total_par4<1) {$total_par4=1;}


//check to make sure if there's no total par5s there's no 0 division!
if ($total_par5<1) {$total_par5=1;}

//1.distance


if ($total_drive<>0) {

$driving_distance=number_format(($total_drive_distance/$total_drive),2,'.','');

} else {

$driving_distance=0;

}



//2.accuracy
if ($poss_fairways>0) {
$pct_fairways_hit=number_format(($total_fairways_hit/$poss_fairways)*100,2,'.','');
} else {
$pct_fairways_hit=0;
}

//3.gir
if ($total_holes_putt<>0) {

$pct_gir=number_format(($total_gir/$total_holes_putt)*100,2,'.','');
} else {

$pct_gir=0;

}

//4.putting average



if ($total_holes_putt<>0) {

$avg_putt=number_format(($total_putts2/$total_holes_putt),2,'.','');

} else {

$avg_putt=0;

}


//OK, look for sandsaves.
if ($total_holes_putt<>0) {
if ($total_bunker2>0) {

$pct_sandsaves=number_format(($total_sandsave/$total_bunker2)*100,2,'.','');
} else {
$pct_sandsaves=0;
}



}
//5.Eagles holes per



//6.Birdies per round of 18

$total_rounds=$total_holes/18;

$avg_birdie=number_format(($total_birdies/$total_rounds),2,'.','');



//6.Pars per round of 18

$avg_par=number_format(($total_par/$total_rounds),2,'.','');



//7.Scoring Average

$avg_gross=number_format(($total_gross/$total_rounds),2,'.','');



//8.Parbreakers, i.e total birdies,eagles over total holes

$total_parbreak=$total_eagles+$total_birdies+$total_double_eagles+$total_holeinone;

$pct_parbreak=number_format(($total_parbreak/$total_holes)*100,2,'.','');



//9.Putts per round

if ($total_putt_rounds) {

//$putts_per_round=number_format(($total_putts1/$total_putt_rounds),2,'.','');

$putts_per_round=number_format(($avg_putt*18),2,'.','');

} else {

$putts_per_round=0;

}

//10.Net Birdies per round of 18

$total_rounds=$total_holes/18;

$net_avg_birdie=number_format(($net_total_birdies/$total_rounds),2,'.','');



//11.Net Pars per round of 18

$net_avg_par=number_format(($net_total_par/$total_rounds),2,'.','');



//12.Net Scoring Average

$avg_net=number_format(($total_net/$total_rounds),2,'.','');



//13.Net Parbreakers, i.e total birdies,eagles over total holes

$net_total_parbreak=$net_total_eagles+$net_total_birdies+$net_total_double_eagles+$net_total_holeinone;

$net_pct_parbreak=number_format(($net_total_parbreak/$total_holes)*100,2,'.','');



//14.Par 3 Birdies Gross Pct

$par3_birdie_pct=number_format(($par3_birdies/$total_par3)*100,2,'.','');



//15.Par 4 Birdies Gross Pct

$par4_birdie_pct=number_format(($par4_birdies/$total_par4)*100,2,'.','');



//16.Par 5 Birdies Gross Pct

$par5_birdie_pct=number_format(($par5_birdies/$total_par5)*100,2,'.','');



//17.Par 3 Par gross Pct

$par3_par_pct=number_format(($par3_pars/$total_par3)*100,2,'.','');



//18.Par 4 Par gross Pct

$par4_par_pct=number_format(($par4_pars/$total_par4)*100,2,'.','');



//19.Par 5 Par gross Pct

$par5_par_pct=number_format(($par5_pars/$total_par5)*100,2,'.','');



//20.Par 3 Performance (Avg) Gross

$par3_avg_score=number_format(($total_par3_scores/$total_par3),2,'.','');



//21.Par 4 Performance (Avg) Gross

$par4_avg_score=number_format(($total_par4_scores/$total_par4),2,'.','');



//22.Par 5 Performance (Avg) Gross

$par5_avg_score=number_format(($total_par5_scores/$total_par5),2,'.','');



//23. Scrambling Gross

if ($missed_gir == 0) {

$scrambling_pct="na";

} else {

$scrambling_pct=number_format((($scrambled_holes)/$missed_gir)*100,2,'.','');

}

//24.Par 3 Birdies net

$net_par3_birdie_pct=number_format(($net_par3_birdies/$total_par3)*100,2,'.','');



//25.Par 4 Birdies net

$net_par4_birdie_pct=number_format(($net_par4_birdies/$total_par4)*100,2,'.','');



//26.Par 5 Birdies net

$net_par5_birdie_pct=number_format(($net_par5_birdies/$total_par5)*100,2,'.','');



//27.Par 3 Par net

$net_par3_par_pct=number_format(($net_par3_pars/$total_par3)*100,2,'.','');



//28.Par 4 Par net

$net_par4_par_pct=number_format(($net_par4_pars/$total_par4)*100,2,'.','');



//29.Par 5 Par net

$net_par5_par_pct=number_format(($net_par5_pars/$total_par5)*100,2,'.','');





//30.Par 3 Performance (Avg) Net

$net_par3_avg_score=number_format(($net_par3_scores/$total_par3),2,'.','');



//31.Par 4 Performance (Avg) Net

$net_par4_avg_score=number_format(($net_par4_scores/$total_par4),2,'.','');



//32.Par 5 Performance (Avg) Net

$net_par5_avg_score=number_format(($net_par5_scores/$total_par5),2,'.','');



//33.Scrambling Net

if ($missed_gir==0) {

$net_scrambling_pct="na";

}else{



$net_scrambling_pct=number_format(((($net_scrambled_holes)/$missed_gir)*100),2,'.','');

}

			

?>
Return current item: GolfstatsPHP