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

include("dbasecon.inc.php");

include("session.inc.php");

include ("header.php");

include ("statscoursefunctions.inc.php");


//get list of players
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">



<? showheader("Player Stats Manager"); ?>

<?
$allusersql="Select userid	
						from users_tour";

				$alluserquery=mysql_query($allusersql);
				$alluserrow=mysql_fetch_array($alluserquery);

do {
$login_id=$alluserrow['userid'];

$hole=0;

//initialise all vars

$total_putts1=0;
$total_drive=0;
$total_drive_distance=0;


//9.putts per round

				$stat5sql="Select * from games 

					where userid = '$login_id'

					 ORDER BY longest_drive ASC";

				$stat5query=mysql_query($stat5sql);

				$stat5row=mysql_fetch_array($stat5query);

				$stat5exist=mysql_numrows($stat5query);

				$longest_drive1=0;

				$total_putts1=0;

if ($stat5exist) { //check if player got stats!



				do {

				extract($stat5row);

				

				if ($total_putts <> "na") {				

				$total_putt_rounds=$total_putt_rounds+1;

				$total_putts1=$total_putts1+$total_putts;

				} //endif



				

				//34.longest drive

				if (($longest_drive <> "na") && ($longest_drive > $longest_drive1)) {				

				$longest_drive1=$longest_drive;

				} //endif

				

				

				} while ($stat5row=mysql_fetch_array($stat5query));
				
include("mainstats.inc.php");			
include("substats.inc.php");			

//first get the current total money and total points

$moneypointssql="Select total_money,total_points from ranking where userid='$login_id'";
$moneypointsquery=mysql_query($moneypointssql);
$moneypointsrow=mysql_fetch_array($moneypointsquery);

 $total_mny=$moneypointsrow["total_money"];
$total_pts=$moneypointsrow["total_points"];
	

$statsdelsql="DELETE FROM ranking where userid='$login_id'";

$statsdelresult=mysql_query($statsdelsql);
 
 

 $statsaddsql = "INSERT INTO ranking (userid, ddistance, daccuracy, dlongest, girpct, puttavg, puttround, sandsavepct,

 totaleagles, totaldoubleeagles, totalholeinone, birdieavg, paravg, avgscore, parbreakers, par3birdies, par4birdies, par5birdies, par3pars, 

 par4pars, par5pars, par3perf, par4perf, par5perf, scrambling, net_totaleagles, net_totaldoubleeagles, net_totalholeinone, net_birdieavg, net_paravg, 

 net_avgscore, net_parbreakers, net_par3birdies, net_par4birdies, net_par5birdies, net_par3pars, net_par4pars, 

 net_par5pars, net_par3perf, net_par4perf, net_par5perf, net_scrambling, total_money, total_points)

  VALUES 

 ('$login_id', '$driving_distance', '$pct_fairways_hit', '$longest_drive1', '$pct_gir', '$avg_putt', '$putts_per_round', '$pct_sandsaves',

 '$total_eagles', '$total_double_eagles', '$total_holeinone', '$avg_birdie', '$avg_par', '$avg_gross', '$pct_parbreak', '$par3_birdie_pct', '$par4_birdie_pct', 

 '$par5_birdie_pct', '$par3_par_pct', '$par4_par_pct', '$par5_par_pct', '$par3_avg_score', '$par4_avg_score', 

 '$par5_avg_score', '$scrambling_pct',

 '$net_total_eagles', '$net_total_double_eagles', '$net_total_holeinone', '$net_avg_birdie', '$net_avg_par', '$avg_net', '$net_pct_parbreak', '$net_par3_birdie_pct', 

 '$net_par4_birdie_pct', '$net_par5_birdie_pct', '$net_par3_par_pct', '$net_par4_par_pct', '$net_par5_par_pct', 

 '$net_par3_avg_score', '$net_par4_avg_score', 

 '$net_par5_avg_score', '$net_scrambling_pct', '$total_mny', '$total_pts')";



		$statsaddresult=mysql_query($statsaddsql);

			
//echo $statsaddsql."<p>";

echo "<h1>Doing Main Stats for $login_id</h1>";

//do the substats


//delete from substats

 $substatsdelsql="DELETE FROM substats where userid='$login_id'";

 $substatsdelresult=mysql_query($substatsdelsql);
 
 
$substatsaddsql="INSERT INTO substats (userid, total_drive_distance, total_drive, total_fairways_hit, poss_fairways, 

total_gir, total_bunker, total_sandsave,total_holes, total_putts2, total_holes_putt, total_birdies, total_rounds, total_par, total_gross, 

total_parbreak, total_putts1, total_putt_rounds, net_total_birdies, net_total_par, total_net, net_total_parbreak, 

par3_birdies, par4_birdies, par5_birdies, par3_pars, par4_pars, par5_pars, total_par3, total_par4, total_par5, 

total_par3_scores, total_par4_scores, total_par5_scores, scrambled_holes, missed_gir, net_par3_birdies, 

net_par4_birdies, net_par5_birdies, net_par3_pars, net_par4_pars, net_par5_pars, net_par3_scores, net_par4_scores, 

net_par5_scores, net_scrambled_holes) 

VALUES 

('$login_id', '$total_drive_distance', '$total_drive', '$total_fairways_hit', '$poss_fairways', '$total_gir', '$total_bunker2', '$total_sandsave', 

'$total_holes', '$total_putts2', '$total_holes_putt', '$total_birdies', '$total_rounds', '$total_par', '$total_gross', 

'$total_parbreak', '$total_putts1', '$total_putt_rounds', '$net_total_birdies', '$net_total_par', '$total_net', '$net_total_parbreak', 

'$par3_birdies','$par4_birdies', '$par5_birdies', '$par3_pars', '$par4_pars', '$par5_pars', '$total_par3', '$total_par4', '$total_par5',

 '$total_par3_scores', '$total_par4_scores', '$total_par5_scores', '$scrambled_holes', '$missed_gir', '$net_par3_birdies', 

 '$net_par4_birdies', '$net_par5_birdies', '$net_par3_pars', '$net_par4_pars', '$net_par5_pars', '$net_par3_scores', '$net_par4_scores',

  '$net_par5_scores', '$net_scrambled_holes')";

echo "<h1>Doing Sub Stats for $login_id</h1>";

$substatsaddresult=mysql_query($substatsaddsql);


} else {

echo "<h1>No games for $login_id!</h1>";

} //endif $stat5exist




//echo $substatsaddsql."<p>########################<p>";
		
} while ($alluserrow=mysql_fetch_array($alluserquery));





?>

<? showfooter(); ?>

Return current item: GolfstatsPHP