Location: PHPKode > projects > GolfstatsPHP > golfstatsphp_3.0/statscoursefunctions.inc.php
<script>

function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements[i]

if (tempobj.name.substring(0,3)=="req"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("Please fill Course Name,course ID, slope and course ratings.")
return false
}
else
return true
}


function msgcheckrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements[i]

if (tempobj.name.substring(0,3)=="req"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("Please fill in message body.")
return false
}
else
return true
}


</script>

<?




function yourcoursestats($userid,$courseid) {

//get all your games on that particular course
$coursechecksql="select * from games where courseid='$courseid'
								 and userid='$userid'";
				$coursecheckquery=mysql_query($coursechecksql);
				$coursecheckrow=mysql_fetch_array($coursecheckquery);
				$coursecheckexist=mysql_numrows($coursecheckquery);

$total_gross=0;
$total_net=0;
if ($coursecheckexist) {

do {
extract($coursecheckrow);

$total_gross=$total_gross+$gross_score;
$total_net=$total_net+$net_score;


} while ($coursecheckrow=mysql_fetch_array($coursecheckquery));				

$avg_gross=number_format(($total_gross/$coursecheckexist),2,'.','');
$avg_net=number_format(($total_net/$coursecheckexist),2,'.','');

$result="$avg_gross, $avg_net";

return $result;

} //endif

}//end function




function avgcoursestats($courseid) {

//get all your games on that particular course
$coursechecksql="select * from games where courseid='$courseid'";
				$coursecheckquery=mysql_query($coursechecksql);
				$coursecheckrow=mysql_fetch_array($coursecheckquery);
				$coursecheckexist=mysql_numrows($coursecheckquery);

$total_gross=0;
$total_net=0;

if ($coursecheckexist) {

do {
extract($coursecheckrow);

$total_gross=$total_gross+$gross_score;
$total_net=$total_net+$net_score;


} while ($coursecheckrow=mysql_fetch_array($coursecheckquery));				

$avg_gross=number_format(($total_gross/$coursecheckexist),2,'.','');
$avg_net=number_format(($total_net/$coursecheckexist),2,'.','');
$result="$avg_gross, $avg_net";

return $result;

} //endif

}//end function











function listpars($max, $choosedigit)
{
	if (!$max) { exit; } # Prevent endless loops

	for($i = 3; $i <= $max; $i++) 
	{
		if ($i < 10) { $val = $i; }
		else { $val = $i; }

		if($i == $choosedigit) { $sel = "selected"; }
		else { $sel = ""; } 

		$makereturn .= "<option $sel value='$val'>$val</option>\n";
    }

	return $makereturn;
}

function listindex($max, $choosedigit)
{
	if (!$max) { exit; } # Prevent endless loops

	for($i = 1; $i <= $max; $i++) 
	{
		if ($i < 10) { $val =  $i; }
		else { $val = $i; }

		if($i == $choosedigit) { $sel = "selected"; }
		else { $sel = ""; } 

		$makereturn .= "<option $sel value='$val'>$val</option>\n";
    }

	return $makereturn;
}


function holestats($top5,$par) {




if (($top5=="avgputt") || ($top5=="gn_avggross") || ($top5=="gn_avgnet")) {
$seq="ASC";
} else {
$seq="DESC";
} //endif seq

//ok, lets format the gn stats!
if ((substr($top5,0,3) == "gn_") || (substr($top5,0,3) == "gnp"))  {

//get rid of the gn
$newtop5=substr($top5,3);

//make % sign for all starting with gnp
if (substr($top5,0,3) == "gnp") { $pct="%"; } else {$pct="";} 
} else {
$newtop5=$top5;
}


$ranksql="Select holerank.courseid,holeid,par,$newtop5,coursename
					from holerank left join courses on holerank.courseid = courses.courseid
					where holerank.par='$par' 
					order by $newtop5 $seq LIMIT 5";
			$rankquery=mysql_query($ranksql);
				$rankrow=mysql_fetch_array($rankquery);
				$rankexist=mysql_numrows($rankquery);

				
return $ranksql;



}//end function

?>
Return current item: GolfstatsPHP