Location: PHPKode > projects > GolfstatsPHP > golfstatsphp_3.0/mainstats.inc.php
<?
//initialise vars
$total_drive=0;
$total_drive_distance=0;
$total_fairways_hit=0;
$poss_fairways=0;
$total_sandsave=0;
//$total_bunker=0;
$scrambled_holes=0;
$net_scrambled_holes=0;
$total_gir=0;
$total_putts2=0;
$total_holes_putt=0;
$total_gross=0;
$total_net=0;
$total_par3=0;
$total_par3_scores=0;
$net_par3_scores=0;
$par3_birdies=0;
$par3_pars=0;
$net_par3_birdies=0;
$net_par3_pars=0;
$total_par4=0;
$total_par4_scores=0;
$net_par4_scores=0;
$par4_birdies=0;
$par4_pars=0;
$net_par4_birdies=0;
$net_par4_pars=0;
$total_par5=0;
$total_par5_scores=0;
$net_par5_scores=0;
$par5_birdies=0;
$par5_pars=0;
$net_par5_birdies=0;
$net_par5_pars=0;
$total_holes=0;
$total_eagles=0;
$total_birdies=0;
$total_par=0;
$net_total_eagles=0;
$net_total_birdies=0;
$net_total_par=0;
$missed_gir=0;
$total_holeinone=0;
$net_total_holeinone=0;
$total_doubleeagle=0;
$net_total_doubleeagle=0;



$hole=0;

do {



$hole=$hole+1;



$table="hole$hole";

//lets get par4 and par5 stats


$statsql="Select * from $table  

					where userid = '$login_id' and	(par='4' or par='5')";

				$statquery=mysql_query($statsql);

				$statrow=mysql_fetch_array($statquery);

				$statexist=mysql_numrows($statquery);



		 		if ($statexist) {



				do {

				extract($statrow);				



				//this is for distance

				if ($drive_distance <> "na") {

				$total_drive=$total_drive+1;				

				$total_drive_distance=$total_drive_distance+$drive_distance;

				} //endif drive distance <> na


				//2.this is for fways hit. There has to be a counting system in which if both putts and distance is na
				//we assume that 

				if ($fairway_hit <> "na") {

				$total_fairways_hit=$total_fairways_hit+$fairway_hit;

				}				


				} while ($statrow=mysql_fetch_array($statquery));

				

				

				} //endif statexist

				
$possfairwaysql="Select * from $table  

					where userid = '$login_id' and	(par='4' or par='5') and fairway_hit<>'na'";

				$possfairwayquery=mysql_query($possfairwaysql);

				$possfairwayrow=mysql_fetch_array($possfairwayquery);

				$possfairwayexist=mysql_numrows($possfairwayquery);

$poss_fairways=$poss_fairways+$possfairwayexist;





				//23. Find scrambling!

				$stat11sql="Select * from $table  

					where userid = '$login_id'

					and (gross_name='Birdie' or gross_name='Par' or gross_name='Eagle' or gross_name='Double Eagle' or gross_name='Hole in one') 

					and gir=0 ";



				$stat11query=mysql_query($stat11sql);

				$stat11row=mysql_fetch_array($stat11query);

				$stat11exist=mysql_numrows($stat11query);

				

				$scrambled_holes=$scrambled_holes+$stat11exist;

				

				//33. Find net scrambling!

								$stat12sql="Select * from $table  

					where userid = '$login_id'

					and (net_name='Birdie' or net_name='Par' or net_name='Eagle' or net_name='Double Eagle' or net_name='Hole in one') 

					and gir=0 ";



				$stat12query=mysql_query($stat12sql);

				$stat12row=mysql_fetch_array($stat12query);

				$stat12exist=mysql_numrows($stat12query);

				

				$net_scrambled_holes=$net_scrambled_holes+$stat12exist;

###############

				

				

				$stat2sql="Select * from $table  

					where userid = '$login_id'";

				$stat2query=mysql_query($stat2sql);

				$stat2row=mysql_fetch_array($stat2query);

				$stat2exist=mysql_numrows($stat2query);



		 		if ($stat2exist) {

				do {

				extract($stat2row);				



				//3.this is for gir

				$total_gir=$total_gir+$gir;

				
				//for sandsaves
				
				$total_sandsave=$total_sandsave+$sand_save;

				$total_bunker2=$total_bunker2+$bunker;


				//4.this is for total putts				

				if ($putt <> "na") {

				$total_putts2=$total_putts2+$putt;

				$total_holes_putt=$total_holes_putt+1;

				} //endif drive distance <> na

												

				

				//7.Scoring Average. Find out the total gross

				$total_gross=$total_gross+$gross;



				//11.Net Scoring Average. Find out the total net

				$total_net=$total_net+$net;

		

				//14.this is for total par 3 holes AND PAR 3 BIRDIES AND PARS FOR gross and net				

				if ($par == 3) {

				$total_par3=$total_par3+1;

				$total_par3_scores=$total_par3_scores+$gross;

				$net_par3_scores=$net_par3_scores+$net;



           if ($gross_name == "Birdie") {

					 $par3_birdies=$par3_birdies+1;

					 }



           if ($gross_name == "Par") {

					 $par3_pars=$par3_pars+1;

					 }



           if ($net_name == "Birdie") {

					 $net_par3_birdies=$net_par3_birdies+1;

					 }



           if ($net_name == "Par") {

					 $net_par3_pars=$net_par3_pars+1;

					 }



				} //endif



				

				

				//15.this is for total par 4 holes AND PAR 4 BIRDIES AND PARS FOR gross and net				

				if ($par == 4) {

				$total_par4=$total_par4+1;

				$total_par4_scores=$total_par4_scores+$gross;

				$net_par4_scores=$net_par4_scores+$net;

			

           if ($gross_name == "Birdie") {

					 $par4_birdies=$par4_birdies+1;

					 }



           if ($gross_name == "Par") {

					 $par4_pars=$par4_pars+1;

					 }



           if ($net_name == "Birdie") {

					 $net_par4_birdies=$net_par4_birdies+1;

					 }



           if ($net_name == "Par") {

					 $net_par4_pars=$net_par4_pars+1;

				}

				


				} //endif



				//16.this is for total par 5 holes AND PAR 3 BIRDIES AND PARS FOR gross and net				

				if ($par == 5) {

				$total_par5=$total_par5+1;

				$total_par5_scores=$total_par5_scores+$gross;

				$net_par5_scores=$net_par5_scores+$net;

				

				

				           if ($gross_name == "Birdie") {

					 $par5_birdies=$par5_birdies+1;

					 }



           if ($gross_name == "Par") {

					 $par5_pars=$par5_pars+1;

					 }



           if ($net_name == "Birdie") {

					 $net_par5_birdies=$net_par5_birdies+1;

					 }



           if ($net_name == "Par") {

					 $net_par5_pars=$net_par5_pars+1;

					 }

				

				

				

				} //endif

				

				

				

				} while ($stat2row=mysql_fetch_array($stat2query));



				} //endif stat2exist


				if ($stat2exist) {
				$total_holes=$total_holes+$stat2exist;
				} else {
				$total_holes=1;
				}







				//5.This is to find eagles for gross

				$stat3sql="Select * from $table  

					where userid = '$login_id'

					and gross_name='Eagle' ";

				$stat3query=mysql_query($stat3sql);

				$stat3row=mysql_fetch_array($stat3query);

				$stat3exist=mysql_numrows($stat3query);

								

				//$total eagles

				$total_eagles=$total_eagles+$stat3exist;

				





			//6.This is to find birdies

				$stat4sql="Select * from $table  

					where userid = '$login_id'

					and gross_name='Birdie' ";

				$stat4query=mysql_query($stat4sql);

				$stat4row=mysql_fetch_array($stat4query);

				$stat4exist=mysql_numrows($stat4query);

								

				//$total birdies

				$total_birdies=$total_birdies+$stat4exist;

				//7.This is to find pars

				$stat5sql="Select * from $table  

					where userid = '$login_id'

					and gross_name='Par' ";

				$stat5query=mysql_query($stat5sql);

				$stat5row=mysql_fetch_array($stat5query);

				$stat5exist=mysql_numrows($stat5query);

								

				//$total pars

				$total_par=$total_par+$stat5exist;

				
				###############Update version 2.0.2 8/3/2007#################

				//This is to find double eagles for gross -- if you get this, you are amazing

				$stat31sql="Select * from $table  

					where userid = '$login_id'

					and gross_name='Double Eagle' ";

				$stat31query=mysql_query($stat31sql);

				$stat31row=mysql_fetch_array($stat31query);

				$stat31exist=mysql_numrows($stat31query);

								

				//$total double eagles

				$total_double_eagles=$total_double_eagles+$stat31exist;
				

				//This is to find hole in one for gross -- less amazing

				$stat32sql="Select * from $table  

					where userid = '$login_id'

					and gross_name='Hole in one' ";

				$stat32query=mysql_query($stat32sql);

				$stat32row=mysql_fetch_array($stat32query);

				$stat32exist=mysql_numrows($stat32query);

								

				//$total holeinones

				$total_holeinone=$total_holeinone+$stat32exist;

##########################end update#####################################

				



								//10.This is to find eagles for net

				$stat7sql="Select * from $table  

					where userid = '$login_id'

					and net_name='Eagle' ";

				$stat7query=mysql_query($stat7sql);

				$stat7row=mysql_fetch_array($stat7query);

				$stat7exist=mysql_numrows($stat7query);

								

				//$total eagles

				$net_total_eagles=$net_total_eagles+$stat7exist;

				
			###############Update version 2.0.2 8/3/2007#################

				//This is to find double eagles for net -- if you get this, you are amazing

				$stat71sql="Select * from $table  

					where userid = '$login_id'

					and net_name='Double Eagle' ";

				$stat71query=mysql_query($stat71sql);

				$stat71row=mysql_fetch_array($stat71query);

				$stat71exist=mysql_numrows($stat71query);

								

				//$total double eagles

				$net_total_double_eagles=$net_total_double_eagles+$stat71exist;
				

				//This is to find hole in one for net -- less amazing

				$stat72sql="Select * from $table  

					where userid = '$login_id'

					and net_name='Hole in one' ";

				$stat72query=mysql_query($stat72sql);

				$stat72row=mysql_fetch_array($stat72query);

				$stat72exist=mysql_numrows($stat72query);

								

				//$total holeinones

				$net_total_holeinone=$net_total_holeinone+$stat72exist;
				
##########################end update#####################################

				

				//11.This is to find birdies

				$stat8sql="Select * from $table  

					where userid = '$login_id'

					and net_name='Birdie' ";

				$stat8query=mysql_query($stat8sql);

				$stat8row=mysql_fetch_array($stat8query);

				$stat8exist=mysql_numrows($stat8query);

								

				//$total birdies

				$net_total_birdies=$net_total_birdies+$stat8exist;

				

				//12.This is to find pars net

				$stat9sql="Select * from $table  

					where userid = '$login_id'

					and net_name='Par' ";

				$stat9query=mysql_query($stat9sql);

				$stat9row=mysql_fetch_array($stat9query);

				$stat9exist=mysql_numrows($stat9query);

								

				//$total pars

				$net_total_par=$net_total_par+$stat9exist;

				



/*

				//14.This is to find par 3 birdies

				$stat10sql="Select * from $table  

					where userid = '$login_id'

					and gross_name='Birdie' 

					and par=3 ";

				$stat10query=mysql_query($stat10sql);

				$stat10row=mysql_fetch_array($stat10query);

				$stat10exist=mysql_numrows($stat10query);

								

				//$total par 3 birds and par 3 holes

				$total_birdies=$total_birdies+$stat10exist;

				

*/



} while ($hole<18);





$missed_gir=$total_holes-$total_gir;

?>
Return current item: GolfstatsPHP