Location: PHPKode > projects > GolfstatsPHP > golfstatsphp_3.0/scoreview1.php
<?

include("dbasecon.inc.php");

include("session.inc.php");

include ("header1.php");

include ("score_functions.inc.php");



$usersql="Select * from users_tour   

					where userid = '$login_id' ";



				$userquery=mysql_query($usersql);

				$userrow=mysql_fetch_array($userquery);

extract($userrow);



$gamesql="select * , date_format(date,'%d/%m/%Y') as real_date from games LEFT JOIN courses 

					ON games.courseid=courses.courseid   

					where games.userid = '$login_id'

					 AND games.gameid='$gameid'";



				$gamequery=mysql_query($gamesql);

				$gamerow=mysql_fetch_array($gamequery);

				$gameexist=mysql_numrows($gamequery);

				

				$gamehandicap=$gamerow['handicap'];

				$coursename=$gamerow['coursename'];

				$courseid=$gamerow['courseid'];

				$courselength=$gamerow['courselength'];

				$front9length=$gamerow['front9length'];

				$back9length=$gamerow['back9length'];



				$out_par=$gamerow['front9'];

				$in_par=$gamerow['back9'];

				$total_par=$gamerow['coursepar'];

				$total_eighteen=$gamerow['gross_score'];

				$total_net=$gamerow['net_score'];

				$total_stableford=$gamerow['stableford'];

				$total_fairway=$gamerow['fairway_hit'];

				$total_gir=$gamerow['gir'];
				
				$total_sandsave=$gamerow['sandsave'];

				$total_putts1=$gamerow['total_putts'];

				$longest_drive=$gamerow['longest_drive'];

				$real_date=$gamerow['real_date'];

							

//now to get the scores of each hole

$hole1sql="select * from hole1   

					where hole1.userid = '$login_id'

					 AND hole1.gameid='$gameid'";



				$hole1query=mysql_query($hole1sql);

				$hole1row=mysql_fetch_array($hole1query);

								

$hole2sql="select * from hole2   

					where hole2.userid = '$login_id'

					 AND hole2.gameid='$gameid'";



				$hole2query=mysql_query($hole2sql);

				$hole2row=mysql_fetch_array($hole2query);



$hole3sql="select * from hole3   

					where hole3.userid = '$login_id'

					 AND hole3.gameid='$gameid'";



				$hole3query=mysql_query($hole3sql);

				$hole3row=mysql_fetch_array($hole3query);



$hole4sql="select * from hole4   

					where hole4.userid = '$login_id'

					 AND hole4.gameid='$gameid'";



				$hole4query=mysql_query($hole4sql);

				$hole4row=mysql_fetch_array($hole4query);



$hole5sql="select * from hole5   

					where hole5.userid = '$login_id'

					 AND hole5.gameid='$gameid'";



				$hole5query=mysql_query($hole5sql);

				$hole5row=mysql_fetch_array($hole5query);



$hole6sql="select * from hole6   

					where hole6.userid = '$login_id'

					 AND hole6.gameid='$gameid'";



				$hole6query=mysql_query($hole6sql);

				$hole6row=mysql_fetch_array($hole6query);



$hole7sql="select * from hole7   

					where hole7.userid = '$login_id'

					 AND hole7.gameid='$gameid'";



				$hole7query=mysql_query($hole7sql);

				$hole7row=mysql_fetch_array($hole7query);



$hole8sql="select * from hole8   

					where hole8.userid = '$login_id'

					 AND hole8.gameid='$gameid'";



				$hole8query=mysql_query($hole8sql);

				$hole8row=mysql_fetch_array($hole8query);

				



$hole9sql="select * from hole9   

					where hole9.userid = '$login_id'

					 AND hole9.gameid='$gameid'";



				$hole9query=mysql_query($hole9sql);

				$hole9row=mysql_fetch_array($hole9query);



				$hole10sql="select * from hole10   

					where hole10.userid = '$login_id'

					 AND hole10.gameid='$gameid'";



				$hole10query=mysql_query($hole10sql);

				$hole10row=mysql_fetch_array($hole10query);





				$hole11sql="select * from hole11   

					where hole11.userid = '$login_id'

					 AND hole11.gameid='$gameid'";



				$hole11query=mysql_query($hole11sql);

				$hole11row=mysql_fetch_array($hole11query);



				$hole12sql="select * from hole12   

					where hole12.userid = '$login_id'

					 AND hole12.gameid='$gameid'";



				$hole12query=mysql_query($hole12sql);

				$hole12row=mysql_fetch_array($hole12query);



				$hole13sql="select * from hole13   

					where hole13.userid = '$login_id'

					 AND hole13.gameid='$gameid'";



				$hole13query=mysql_query($hole13sql);

				$hole13row=mysql_fetch_array($hole13query);



				$hole14sql="select * from hole14   

					where hole14.userid = '$login_id'

					 AND hole14.gameid='$gameid'";



				$hole14query=mysql_query($hole14sql);

				$hole14row=mysql_fetch_array($hole14query);



				$hole15sql="select * from hole15   

					where hole15.userid = '$login_id'

					 AND hole15.gameid='$gameid'";



				$hole15query=mysql_query($hole15sql);

				$hole15row=mysql_fetch_array($hole15query);



				$hole16sql="select * from hole16   

					where hole16.userid = '$login_id'

					 AND hole16.gameid='$gameid'";



				$hole16query=mysql_query($hole16sql);

				$hole16row=mysql_fetch_array($hole16query);



				$hole17sql="select * from hole17   

					where hole17.userid = '$login_id'

					 AND hole17.gameid='$gameid'";



				$hole17query=mysql_query($hole17sql);

				$hole17row=mysql_fetch_array($hole17query);



				$hole18sql="select * from hole18   

					where hole18.userid = '$login_id'

					 AND hole18.gameid='$gameid'";



				$hole18query=mysql_query($hole18sql);

				$hole18row=mysql_fetch_array($hole18query);





?>

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



<? showheader("Score Cards"); ?>



<p>



<table border=0 width="30%">

<tr><td>

<FORM> 

<INPUT type="button" value="Close Score Card" 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 Score Card";



function printpage() {

window.print();  

}



document.write("<form><input type=button "

+"value=\""+message+"\" onClick=\"printpage()\"></form>");



//-->

</script>

</td></tr>

</table>



<p>



<?





if ($gameexist) {

echo "<table border=1 cellpadding='5'><tr class='menu-bg'><td>Date</td><td>Course</td><td>Player</td><td>Handicap</td></tr>";

echo "<tr><td>$real_date</td>";

echo "<td>$coursename</td><td>$name $surname</td>";

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

echo "<p>"

?>

<table border=1>

<tr class='menu-bg'>

<td>Hole</td><td>Par</td><td><? echo $measure; ?></td><td>Index</td><td>Score</td><td>Gr.Name</td><td>Net</td>

<td>Net.Name</td><td>Stableford</td><td>Fway</td><td>GIR</td><td>Snd.<br>Save</td><td>Putt</td><td>Drive</td><td>Club</td>

</tr>





<?

$hole=0;

do {



$hole=$hole+1;

$holerow=hole.$hole.row;



extract(${$holerow});



//get the current hole index 

$indexhole=indexhole.$hole;

$lengthhole=lengthhole.$hole;



$indexsql="Select * from courses  

					where courseid = '$courseid'";



				$indexquery=mysql_query($indexsql);

				$indexrow=mysql_fetch_array($indexquery);



				extract($indexrow);



//now get the clubs used

$clubsql="Select * from clubs 

					where clubid = '$teeclub'";



				$clubquery=mysql_query($clubsql);

				$clubrow=mysql_fetch_array($clubquery);



				extract($clubrow);











//if gir or fairway hit, use a bullet

if ($fairway_hit == 1) {

$fway_hit_bull = "&#8226";

} else {

$fway_hit_bull = "&nbsp;";

}



if ($gir == 1) {

$gir_bull = "&#8226";

} else {

$gir_bull = "&nbsp;";

}

if ($sand_save == 1) {

$sandsave_bull = "&#8226";

} else {

$sandsave_bull = "&nbsp;";

}

//find the out and in nine



if ($hole <= 9) {

$out_nine=$out_nine+$gross;



//find the out strokes



$out_net=$out_net+$net;

$out_stableford=$out_stableford+$stableford_pts;

$out_putts=$out_putts+$putt;

//$out_drive_distance=$out_drive_distance+$drive_distance;

$out_strokes=$out_nine-$out_par;

$net_out_strokes=$out_net-$out_par;



		if ($out_strokes > 0) {

		$out_strokes="+$out_strokes";

		

		}

		if ($net_out_strokes > 0) {

		$net_out_strokes="+$net_out_strokes";

		

		}



		if ($fairway_hit == 1) {

		$out_fairway=$out_fairway+1;

		}



		

		if ($gir == 1) {

		$out_gir=$out_gir+1;

		}

		if ($sandsave== 1) {

		$out_sandsave=$out_sandsave+1;

		}

		if (($drive_distance > $out_drive) && ($drive_distance <> "na")) {

		$out_drive=$drive_distance;		

		}

} else {

$in_nine=$in_nine+$gross;





$in_net=$in_net+$net;

$in_stableford=$in_stableford+$stableford_pts;

$in_putts=$in_putts+$putt;

$in_drive_distance=$in_drive_distance+${$drive};

$in_strokes=$in_nine-$in_par;

$net_in_strokes=$in_net-$in_par;



		if ($in_strokes > 0) {

		$in_strokes="+$in_strokes";

		

		}

		if ($net_in_strokes > 0) {

		$net_in_strokes="+$net_in_strokes";

		

		}



		if ($fairway_hit == 1) {

		$in_fairway=$in_fairway+1;

		}



		

		if ($gir == 1) {

		$in_gir=$in_gir+1;

		}

		if ($sandsave == 1) {

		$in_sandsave=$in_save+1;

		}

		if (($drive_distance > $in_drive)  && ($drive_distance <> "na")) {

		$in_drive=$drive_distance;		

		}









} //endif hole < 9





$total_strokes=$out_strokes+$in_strokes;

$total_net_strokes=$net_out_strokes+$net_in_strokes;







			if ($total_strokes > 0) {

		$total_strokes="+$total_strokes";

		

		}



			if ($total_net_strokes > 0) {

		$total_net_strokes="+$total_net_strokes";



		}

		

if ($in_drive > $out_drive) {

$total_drive=$in_drive;

} else {



$total_drive=$out_drive;

}





//add some color to your world!

if (($gross_name=='Hole in one') || ($gross_name=='Double Eagle')) {

$color='#CC3366';

} elseif ($gross_name=='Eagle') {

$color='#ffff00';

} elseif ($gross_name=='Birdie') {

$color='#33ccff';

} elseif ($gross_name=='Par') {

$color='#ffcccc';

} elseif ($gross_name=='Bogey') {

$color='#CC0000';

} else {

$color='#339933';

}



if (($net_name=='Hole in one') || ($net_name=='Double Eagle')) {

$color2='#CCCC00';

} elseif ($net_name=='Eagle') {

$color2='#ffff00';

} elseif ($net_name=='Birdie') {

$color2='#33ccff';

} elseif ($net_name=='Par') {

$color2='#ffcccc';

} elseif ($net_name=='Bogey') {

$color2='#CC0000';

} else {

$color2='#339933';

}



//$total_net_strokes+1;



echo "<tr align='center'><td>$hole</td><td>$par</td><td>${$lengthhole}</td><td>${$indexhole}</td>";

echo "<td bgcolor='$color'>$gross</td>";

echo "<td bgcolor='$color'>$gross_name</td>";

echo "<td bgcolor='$color2'>$net</td>";

echo "<td bgcolor='$color2'>$net_name</td>";

echo "<td>$stableford_pts</td>";

echo "<td align='center'>$fway_hit_bull</td>";

echo "<td align='center'>$gir_bull</td>";

echo "<td align='center'>$sandsave_bull</td>";

echo "<td>$putt</td>";

echo "<td>$drive_distance</td>";

echo "<td>$clubs</td>";

echo "<tr>";





if ($hole==9) {

echo "<tr class='menu-bg' align='center'><td>OUT</td><td>$out_par</td><td>$front9length</td><td>OUT</td>";

echo "<td>$out_nine</td>";

echo "<td>";

echo "$out_strokes</td>";

echo "<td>$out_net</td>";

echo "<td>$net_out_strokes</td>";

echo "<td>$out_stableford</td>";

echo "<td>$out_fairway</td>";

echo "<td>$out_gir</td>";

echo "<td>$out_sandsave</td>";

echo "<td>$out_putts</td>";

echo "<td>$out_drive *</td>";

echo "<td>&nbsp;</td>";



echo "</tr>";



} //endif hole9







}while ($hole<18); //end while. Elegant code!



echo "<tr class='menu-bg' align='center'><td>IN</td><td>$in_par</td><td>$back9length</td><td>IN</td>";

echo "<td>$in_nine</td>";

echo "<td>";

echo "$in_strokes</td>";

echo "<td>$in_net</td>";

echo "<td>$net_in_strokes</td>";

echo "<td>$in_stableford</td>";

echo "<td>$in_fairway</td>";

echo "<td>$in_gir</td>";

echo "<td>$in_putts</td>";

echo "<td>$in_sandsave</td>";

echo "<td>$in_drive *</td>";

echo "<td>&nbsp;</td>";



echo "</tr>";



echo "<tr class='menu-bg' align='center'><td>OUT</td><td>$out_par</td><td>$front9length</td><td>OUT</td>";

echo "<td>$out_nine</td>";

echo "<td>";

echo "$out_strokes</td>";

echo "<td>$out_net</td>";

echo "<td>$net_out_strokes</td>";

echo "<td>$out_stableford</td>";

echo "<td>$out_fairway</td>";

echo "<td>$out_gir</td>";

echo "<td>$out_sandsave</td>";

echo "<td>$out_putts</td>";

echo "<td>$out_drive *</td>";

echo "<td>&nbsp;</td>";



echo "</tr>";



//some cleanup to make sure putts and drive are na if it is 0

if (!$total_drive) {

$total_drive="na";

}				



if (!$total_putts) {



$total_putts="na";

}





echo "<tr class='menu-bg' align='center'><td>TOTAL</td><td>$total_par</td><td>$courselength</td><td>INDEX</td>";

echo "<td>$total_eighteen</td>";

echo "<td>$total_strokes</td>";

echo "<td>$total_net</td>";

echo "<td>$total_net_strokes</td>";

echo "<td>$total_stableford</td>";

echo "<td>$total_fairway</td>";

echo "<td>$total_gir</td>";

echo "<td>$total_sandsave</td>";

echo "<td>$total_putts1</td>";

echo "<td>$longest_drive *</td>";

echo "<td>&nbsp;</td>";



echo "</tr>";





?>



</table>



<?



} else {



echo "Please enter score cards <a href='statsmain.php'>here</a>.";

} //endif gameexist

?>





	 

<? showfooter(); ?>

Return current item: GolfstatsPHP