Location: PHPKode > projects > GolfstatsPHP > golfstatsphp_3.0/holestats.php
<?
include("dbasecon.inc.php");
include("session.inc.php");
include ("header1.php");
include ("statscoursefunctions.inc.php");


if ($HTTP_GET_VARS['courseid']) {

//first check see if course already exist
$parhole="parhole".$hole;
$indexhole="indexhole".$hole;
$lengthhole="lengthhole".$hole;

$coursechecksql="select $parhole,$indexhole,$lengthhole,coursename from courses where courseid='$courseid'";
				$coursecheckquery=mysql_query($coursechecksql);
				$coursecheckrow=mysql_fetch_array($coursecheckquery);
				$coursecheckexist=mysql_numrows($coursecheckquery);
				
$holeid="hole".$hole;

//get global stats

$holestatssql="select * from $holeid where courseid='$courseid'";
				$holestatquery=mysql_query($holestatssql);
				$holestatcheckrow=mysql_fetch_array($holestatquery);
				$holestatcheckexist=mysql_numrows($holestatquery);
				
if ($coursecheckexist) {				




?>

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

<? showheader("Course Manager"); ?>


<? echo "<p class='error'>".$error."<p>"; ?>


<p>
<table border=0 width="30%">
<tr><td>
<FORM> 
<INPUT type="button" value="Close Hole Stats" onClick="window.close()"> 
</FORM> 
</td><td>
<script language="Javascript1.2">
<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com

var message = "Print Hole Stats";

function printpage() {
window.print();  
}

document.write("<form><input type=button "
+"value=\""+message+"\" onClick=\"printpage()\"></form>");

//-->
</script>
</td></tr>
</table>
<?
extract($coursecheckrow);


?>
<table width="100%" border=0>
<tr><td>

<table border=1 width=60%>
<tr>
<td class="menu-bg">Course ID</td><td><? echo $courseid ?></td></tr><tr>
<td class="menu-bg">Name</td><td><? echo $coursename ?></td></tr><tr>
<td class="menu-bg">Hole</td><td><? echo $hole ?></td>
</tr><tr>
<td class="menu-bg">Par</td><td><? echo $$parhole ?></td></tr><tr>
<td class="menu-bg">Index</td><td><? echo $$indexhole ?></td></tr><tr>
<td class="menu-bg"><?echo $measure;?></td><td><? echo $$lengthhole ?></td></tr><tr>
<td class="menu-bg">Rank</td><td><? echo $rankhole ?></td></tr><tr>

</table>

</td>
<td>
<table border=1 width=100%>
<tr>
</tr><tr>
</tr>
</table>

</td>
</tr>
</table>
<?






?>

<?
//1.check number of times user has played
$holesql="select * from $holeid where courseid='$courseid' AND userid='$login_id'";
				$holequery=mysql_query($holesql);
				$holecheckrow=mysql_fetch_array($holequery);
				$holecheckexist=mysql_numrows($holequery);

				
//1.get global stats for double eagle
$globdoubleeagles="Select * from $holeid where courseid='$courseid' and (gross_name='Double Eagle' or gross_name='Hole In One')";
				$globdoubleeaglesquery=mysql_query($globdoubleeagles);
				$globgrossDeagle=mysql_numrows($globdoubleeaglesquery);
				if (!$globgrossDeagle) { $globgrossDeagle="0";}
//2.				
$globeagles="Select * from $holeid where courseid='$courseid' and gross_name='Eagle'";
				$globeaglesquery=mysql_query($globeagles);
				$globgrosseagles=mysql_numrows($globeaglesquery);
				if (!$globgrosseagles) { $globgrosseagles="0";}

//2.				
$globbirdies="Select * from $holeid where courseid='$courseid' and gross_name='Birdie'";
				$globbirdiesquery=mysql_query($globbirdies);
				$globgrossbirdies=mysql_numrows($globbirdiesquery);
				if (!$globgrossbirdies) { $globgrossbirdies="0";}

//2.				
$globpars="Select * from $holeid where courseid='$courseid' and gross_name='Par'";
				$globparsquery=mysql_query($globpars);
				$globgrosspars=mysql_numrows($globparsquery);
				if (!$globgrosspars) { $globgrosspars="0";}

//2.				
$globbogeys="Select * from $holeid where courseid='$courseid' and gross_name='Bogey'";
				$globbogeysquery=mysql_query($globbogeys);
				$globgrossbogeys=mysql_numrows($globbogeysquery);
				if (!$globgrossbogeys) { $globgrossbogeys="0";}

$globothers="Select * from $holeid where courseid='$courseid' and gross_name != 'Par'
and gross_name != 'Bogey' and gross_name !='Birdie' and gross_name !='Eagle' and gross_name !='Double Eagle'
and gross_name != 'Hole in one'";
				$globothersquery=mysql_query($globothers);
				$globgrossothers=mysql_numrows($globothersquery);
				if (!$globgrossothers) { $globgrossothers="0";}
				
				
				
//get player stats for gross
//1.get global stats for double eagle
$userdoubleeagles="Select * from $holeid where courseid='$courseid' AND userid='$login_id' and (gross_name='Double Eagle' or gross_name='Hole In One')";
				$userdoubleeaglesquery=mysql_query($userdoubleeagles);
				$usergrossDeagle=mysql_numrows($userdoubleeaglesquery);
				if (!$usergrossDeagle) { $usergrossDeagle="0";}
//2.				
$usereagles="Select * from $holeid where courseid='$courseid' AND userid='$login_id' and gross_name='Eagle'";
				$usereaglesquery=mysql_query($usereagles);
				$usergrosseagles=mysql_numrows($usereaglesquery);
				if (!$usergrosseagles) { $usergrosseagles="0";}

//2.				
$userbirdies="Select * from $holeid where courseid='$courseid' AND userid='$login_id' and gross_name='Birdie'";
				$userbirdiesquery=mysql_query($userbirdies);
				$usergrossbirdies=mysql_numrows($userbirdiesquery);
				if (!$usergrossbirdies) { $usergrossbirdies="0";}

//2.				
$userpars="Select * from $holeid where courseid='$courseid' AND userid='$login_id' and gross_name='Par'";
				$userparsquery=mysql_query($userpars);
				$usergrosspars=mysql_numrows($userparsquery);
				if (!$usergrosspars) { $usergrosspars="0";}

//2.				
$userbogeys="Select * from $holeid where courseid='$courseid' AND userid='$login_id' and gross_name='Bogey'";
				$userbogeysquery=mysql_query($userbogeys);
				$usergrossbogeys=mysql_numrows($userbogeysquery);
				if (!$usergrossbogeys) { $usergrossbogeys="0";}

$userothers="Select * from $holeid where courseid='$courseid' AND userid='$login_id' and gross_name != 'Par'
and gross_name != 'Bogey' and gross_name !='Birdie' and gross_name !='Eagle' and gross_name !='Double Eagle'
and gross_name != 'Hole in one'";
				$userothersquery=mysql_query($userothers);
				$usergrossothers=mysql_numrows($userothersquery);
				if (!$usergrossothers) { $usergrossothers="0";}				
				

//now get global-net-score
//1.check number of times user has played
$holesql="select * from $holeid where courseid='$courseid' AND userid='$login_id'";
				$holequery=mysql_query($holesql);
				$holecheckrow=mysql_fetch_array($holequery);
				$holecheckexist=mysql_numrows($holequery);

				
//1.get global stats for double eagle
$globdoubleeagles="Select * from $holeid where courseid='$courseid' and (net_name='Double Eagle' or net_name='Hole In One')";
				$globdoubleeaglesquery=mysql_query($globdoubleeagles);
				$globnetDeagle=mysql_numrows($globdoubleeaglesquery);
				if (!$globnetDeagle) { $globnetDeagle="0";}
//2.				
$globeagles="Select * from $holeid where courseid='$courseid' and net_name='Eagle'";
				$globeaglesquery=mysql_query($globeagles);
				$globneteagles=mysql_numrows($globeaglesquery);
				if (!$globneteagles) { $globneteagles="0";}

//2.				
$globbirdies="Select * from $holeid where courseid='$courseid' and net_name='Birdie'";
				$globbirdiesquery=mysql_query($globbirdies);
				$globnetbirdies=mysql_numrows($globbirdiesquery);
				if (!$globnetbirdies) { $globnetbirdies="0";}

//2.				
$globpars="Select * from $holeid where courseid='$courseid' and net_name='Par'";
				$globparsquery=mysql_query($globpars);
				$globnetpars=mysql_numrows($globparsquery);
				if (!$globnetpars) { $globnetpars="0";}

//2.				
$globbogeys="Select * from $holeid where courseid='$courseid' and net_name='Bogey'";
				$globbogeysquery=mysql_query($globbogeys);
				$globnetbogeys=mysql_numrows($globbogeysquery);
				if (!$globnetbogeys) { $globnetbogeys="0";}

$globothers="Select * from $holeid where courseid='$courseid' and net_name != 'Par'
and net_name != 'Bogey' and net_name !='Birdie' and net_name !='Eagle' and net_name !='Double Eagle'
and net_name != 'Hole in one'";
				$globothersquery=mysql_query($globothers);
				$globnetothers=mysql_numrows($globothersquery);
				if (!$globnetothers) { $globnetothers="0";}				
				
				
//now get user-net-scores				
//get player stats for net
//1.get global stats for double eagle
$userdoubleeagles="Select * from $holeid where courseid='$courseid' AND userid='$login_id' and (net_name='Double Eagle' or net_name='Hole In One')";
				$userdoubleeaglesquery=mysql_query($userdoubleeagles);
				$usernetDeagle=mysql_numrows($userdoubleeaglesquery);
				if (!$usernetDeagle) { $usernetDeagle="0";}
//2.				
$usereagles="Select * from $holeid where courseid='$courseid' AND userid='$login_id' and net_name='Eagle'";
				$usereaglesquery=mysql_query($usereagles);
				$userneteagles=mysql_numrows($usereaglesquery);
				if (!$userneteagles) { $userneteagles="0";}

//2.				
$userbirdies="Select * from $holeid where courseid='$courseid' AND userid='$login_id' and net_name='Birdie'";
				$userbirdiesquery=mysql_query($userbirdies);
				$usernetbirdies=mysql_numrows($userbirdiesquery);
				if (!$usernetbirdies) { $usernetbirdies="0";}

//2.				
$userpars="Select * from $holeid where courseid='$courseid' AND userid='$login_id' and net_name='Par'";
				$userparsquery=mysql_query($userpars);
				$usernetpars=mysql_numrows($userparsquery);
				if (!$usernetpars) { $usernetpars="0";}

//2.				
$userbogeys="Select * from $holeid where courseid='$courseid' AND userid='$login_id' and net_name='Bogey'";
				$userbogeysquery=mysql_query($userbogeys);
				$usernetbogeys=mysql_numrows($userbogeysquery);
				if (!$usernetbogeys) { $usernetbogeys="0";}

$userothers="Select * from $holeid where courseid='$courseid' AND userid='$login_id' and net_name != 'Par'
and net_name != 'Bogey' and net_name !='Birdie' and net_name !='Eagle' and net_name !='Double Eagle'
and net_name != 'Hole in one'";
				$userothersquery=mysql_query($userothers);
				$usernetothers=mysql_numrows($userothersquery);
				if (!$usernetothers) { $usernetothers="0";}				
				
?>

<table border=1 width="60%">
<tr class="menu-bg">
<td width="20%">&nbsp;</td><td>Your Stats</td><td>Global Stats</td>

</tr>


<tr>
<td class="menu-bg">Played</td><td><?echo $holecheckexist;?></td><td><?echo $holestatcheckexist;?></td>
</tr>
<tr>
<td class="menu-bg">Gross Hole-in-one/Double Eagle</td><td><?echo $usergrossDeagle;?></td><td><?echo $globgrossDeagle; ?></td>
</tr>

<tr>
<td class="menu-bg">Gross Eagles</td><td><?echo $usergrosseagles;?></td><td><?echo $globgrosseagles; ?></td>
</tr>
<tr>
<td class="menu-bg">Gross Birdies</td><td><?echo $usergrossbirdies;?></td><td><?echo $globgrossbirdies; ?></td>
</tr>
<tr>
<td class="menu-bg">Gross Pars</td><td><?echo $usergrosspars;?></td><td><?echo $globgrosspars; ?></td>
</tr>
<tr>
<td class="menu-bg">Gross Bogeys</td><td><?echo $usergrossbogeys;?></td><td><?echo $globgrossbogeys; ?></td>
</tr>
<tr>
<td class="menu-bg">Gross Others</td><td><?echo $usergrossothers;?></td><td><?echo $globgrossothers; ?></td>
</tr>
</table>
<table width='100%'>
<tr><td>
<? if ($holecheckexist) {?>

<img src="tempcharts/gross<? echo $login_id; ?>.jpg?<?echo time()?>">
<? } else {

echo "<b>No Statistics for player $login_id</b><p>";
}
?>

</td>
<td>
<img src="tempcharts/grossglobal.jpg?<?echo time()?>">
</td>
</tr>
</table>
<table border=1 width='60%'>
<tr>
<td width='20%' class="menu-bg">Net Hole-in-one/Double Eagle</td><td><?echo $usernetDeagle;?></td><td><?echo $globnetDeagle; ?></td>
</tr>

<tr>
<td class="menu-bg">Net Eagles</td><td><?echo $userneteagles;?></td><td><?echo $globneteagles; ?></td>
</tr>
<tr>
<td class="menu-bg">Net Birdies</td><td><?echo $usernetbirdies;?></td><td><?echo $globnetbirdies; ?></td>
</tr>
<tr>
<td class="menu-bg">Net Pars</td><td><?echo $usernetpars;?></td><td><?echo $globnetpars; ?></td>
</tr>
<tr>
<td class="menu-bg">Net Bogeys</td><td><?echo $usernetbogeys;?></td><td><?echo $globnetbogeys; ?></td>
</tr>
<tr>
<td class="menu-bg">Net Others</td><td><?echo $usernetothers;?></td><td><?echo $globnetothers; ?></td>
</tr>

</table>
<table width='100%'>
<tr><td width='%50'>
<? if ($holecheckexist) {?>
<img src="tempcharts/net<? echo $login_id; ?>.jpg?<?echo time()?>">
<? } else {

echo "<b>No Statistics for player $login_id</b><p>";
}
?>
</td>
<td>
<img src="tempcharts/netglobal.jpg?<?echo time()?>">
</td>
</tr>
</table>
</table>
<table width='100%'>
<tr><td width='%50'>
<? if ($holecheckexist) {?>
<img src="tempcharts/averagebar<?echo $login_id;?>.jpg?<?echo time()?>">
<? } else {

echo "<b>No Statistics for player $login_id</b><p>";
}
?>

</td>
<td>
<? if ($holecheckexist) {?>
<img src="tempcharts/averagebar2<?echo $login_id;?>.jpg?<?echo time()?>">
<? } else {

echo "<b>No Statistics for player $login_id</b><p>";
}
?>

</td>
</tr>
</table>
<p>
<? if ($holecheckexist) {?>
<img src="tempcharts/scoreline<?echo $login_id;?><?echo $courseid;?>.jpg?<?echo time()?>">
<? } else {

echo "<b>No Statistics for player $login_id</b><p>";
}
?>

<p>

<FORM> 
<INPUT type="button" value="Close Hole Stats" onClick="window.close()"> 
</FORM> 



<?

} else {

echo "Course does not exist!";

}


} else {

echo "Internal Error.";
}

?>

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