Location: PHPKode > projects > GolfstatsPHP > golfstatsphp_3.0/management.php
<?
include("dbasecon.inc.php");
include("session.inc.php");
include ("header.php");
include ("sf.php");
include ("score_functions.inc.php");



?>

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

<? showheader("Management Center"); ?>

<p>

<?



if ($login_id==$rootid) {




if ($HTTP_POST_VARS['addramble']) {



if ($reqmsgbody) {

$error="Ramble has been posted.";

//format date

$today=date("Y-m-d");                           

$time=date("H:i:s");                           

$insertsql="INSERT INTO msgboard (date, msgtime, userid, message,rambleid) VALUES ('$today','$time', '$rambler_id', '$reqmsgbody','$ramblenext')";
$insertquery=mysql_query($insertsql);


} else {

$error="No message posted.";

}//endif msgbody


} //endif addramble



//ok, lets find out all the tourneys first
$tourneysql="select tourneyid  from tourney";
$tourneyquery=mysql_query($tourneysql);
$tourneyrow=mysql_fetch_array($tourneyquery);
$tourneyexist=mysql_numrows($tourneyquery); 


###########################User Deleted################################

if ($HTTP_POST_VARS['deleteuser']) {

//make sure you don't delete rootid

if ($user_del==$rootid) {
	 $error="User $userid is root id. You shouldn't delete this guy!";
	 
} else {

	 //1.delete from users_tour
	 	 $userdelsql= "Delete From users_tour where (userid='$user_del')";
	 $userdelresult=mysql_query($userdelsql);
		 
		 //1.delete from users_clubs
	 	 $userdelsql= "Delete From users_clubs where (userid='$user_del')";
	 $userdelresult=mysql_query($userdelsql); 
	//2.now delete from gameorg
	 
	 $userdelsql= "Delete From gameorg where (userid='$user_del')";
	 $userdelresult=mysql_query($userdelsql);
	 

	 
	 //3.now delete from games
	 $userdelsql= "Delete From games where (userid='$user_del')";
	 $userdelresult=mysql_query($userdelsql);
	 
	 //4.now delete from ranking
	  $userdelsql= "Delete From ranking where (userid='$user_del')";
		$userdelresult=mysql_query($userdelsql);

			 //5.now delete from substats
	  $userdelsql= "Delete From substats where (userid='$user_del')";
		$userdelresult=mysql_query($userdelsql);

//5.now we run through hole1 to hole18
$hole=0;
do {
$hole++;
$table="hole$hole";

$userdelsql= "Delete From $table where (userid='$user_del')";
$userdelresult=mysql_query($userdelsql);

} while ($hole<18);

//now the main cruncher is that all player's stats need to be recalculated one by one!!!


//6. now we recalculate! I seriously need to put this thing into a function....

//first find all players!
//get the list of all users
$allusersql="Select userid	
						from users_tour";

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

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

$hole=0;

//echo "Processing for $login_id<p>";

//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 ($stat5row) {
				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));


} //endif $stat5row







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>";




//delete from substats

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

 $substatsdelresult=mysql_query($substatsdelsql);



//do the substats

$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')";



$substatsaddresult=mysql_query($substatsaddsql);



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

		
		######################################END###################################

	 $error="User $user_del has been deleted.";
	 
	 




} //endif user_del==rootid








}
###########################Course Deleted################################

if ($HTTP_POST_VARS['deletecourse']) {

//first checkif course_del has a tournament
$tourneychecksql="select tourneyid  from tourney where tourneyvenue='$course_del'";
$tourneycheckquery=mysql_query($tourneychecksql);
$tourneycheckrow=mysql_fetch_array($tourneycheckquery);
$tourneycheckexist=mysql_numrows($tourneycheckquery); 

   if (!$tourneycheckexist) {
	 //ok, lets start the deletion!!
	 
	 //1. First, we delete from courses
$coursedelsql= "Delete From courses where (courseid='$course_del')";
$coursedelresult=mysql_query($coursedelsql);

	//2.now delete from gameorg
	 
	 $coursedelsql= "Delete From gameorg where (courseid='$course_del')";
	 $coursedelresult=mysql_query($coursedelsql);
	 
	 //3.now delete from games
	 $coursedelsql= "Delete From games where (courseid='$course_del')";
	 $coursedelresult=mysql_query($coursedelsql);
	 
	 //4.now delete from holerank
	  $coursedelsql= "Delete From holerank where (courseid='$course_del')";
		$coursedelresult=mysql_query($coursedelsql);

//5.now we run through hole1 to hole18
$hole=0;
do {
$hole++;
$table="hole$hole";

$coursedelsql= "Delete From $table where (courseid='$course_del')";
$coursedelresult=mysql_query($coursedelsql);

} while ($hole<18);

//now the main cruncher is that all player's stats need to be recalculated one by one!!!


//6. now we recalculate! I seriously need to put this thing into a function....

//first find all players!
//get the list of all users
$allusersql="Select userid	
						from users_tour";

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

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

$hole=0;

//echo "Processing for $login_id<p>";

//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;

				

				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, 

 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', 

 '$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>";




//delete from substats

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

 $substatsdelresult=mysql_query($substatsdelsql);



//do the substats

$substatsaddsql="INSERT INTO substats (userid, total_drive_distance, total_drive, total_fairways_hit, poss_fairways, 

total_gir, 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_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')";



$substatsaddresult=mysql_query($substatsaddsql);



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

		
		######################################END###################################

	 $error="Course $course_del has been deleted.";
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 } else {
	 
	 $error="There's a tournament associated with this course. Please delete tournament first!";
	 } //endif tourneycheckexist



} //endif deletecourse



##############################Tourney Added###############################
//ok, if tournament added
if ($HTTP_POST_VARS['createtourney']) {

//date and venue must be gotten from the tourneyid
//get year-month-day
$year = substr("$gametourneyid", 0, 4); 
$month = substr("$gametourneyid", 4, 2); 
$day = substr("$gametourneyid", 6, 2); 
$tourney_date=$year."-".$month."-".$day;

//get tourney venue
$tourney_venue=substr("$gametourneyid", 8, 5);

//ok, check if there's a tournament existing!
$tourney1sql="select tourneyid  from tourney where tourneyid='$gametourneyid'";
$tourney1query=mysql_query($tourney1sql);
$tourney1exist=mysql_numrows($tourney1query); 


if ($tourney1exist) {								
 $tourneychangesql = "Update tourney Set tourneyname='$reqtourney_name',tourneytype='$reqtourney_type', tourneypurse='$reqtourney_purse' 
 where tourneyid = '$gametourneyid'"; 

$tourneychangeresult=mysql_query($tourneychangesql);

$error="Tournament $reqtourney_name has been updated.";

} else {
$insertsql="INSERT INTO tourney (tourneyid, tourneyname, tourneytype, tourneyvenue, date, tourneypurse) 
VALUES ('$gametourneyid','$reqtourney_name', '$reqtourney_type', '$tourney_venue','$tourney_date','$reqtourney_purse')";

$insertquery=mysql_query($insertsql);

$error="Tournament $reqtourney_name has been created.";

}//endif tourney1exist

}//endif create tourney

##############################End tourney Add#################################



##############################Tourney Delete####################################


//ok, if tournament added
if ($HTTP_POST_VARS['deletetourney']) {

//delete from all three tourney tables
$tourneydelsql= "Delete From tourney where (tourneyid='$tourneyid_del')";
$tourneydelresult=mysql_query($tourneydelsql);

$tourneydelsql= "Delete From tourney_board where (tourneyid='$tourneyid_del')";
$tourneydelresult=mysql_query($tourneydelsql);

$tourneydelsql= "Delete From tourney_stat where (tourneyid='$tourneyid_del')";
$tourneydelresult=mysql_query($tourneydelsql);


//we don't delete games here but we do set the tournament field in games to 0, i.e no longer a tournament
$tourneydelsql= "Update games set tournament='0', tourneyplace='0', money='0', points='0' where (gameid='$tourneyid_del')";
$tourneydelresult=mysql_query($tourneydelsql);

$error="Tournament $tourneyid has been deleted. The games in tournament $tourneyid has been set to non-tournament games. They need to be manually deleted by respective users.";
}//endif deletetourney tourney




##############################End tourney Delete################################

echo "<h2>Management Center</h2><p>";
echo "<p class='error'>$error <p>";
echo "<table border=1 width=90%>";

echo "<tr>";
echo "<td class=bg0 width=20%><a href='updateplayerpoints.php'>Update Player Points</a></td><td>This script needs to be run either manually or by system cron each time a game, or group of 
games are entered. It calculates and ranks the players</td></tr>";

echo "<tr>";
echo "<td class=bg0 width=20%><a href='updateplayerstats.php'>Update Player Stats</a></td><td>This script needs to be run either manually or by system cron each time a game, or group of 
games are entered. It the main and sub statistics of the players.</td></tr>";

echo "<tr>";
echo "<td class=bg0 width=20%><a href='updatecourseranks.php'>Update Hole Ranks</a></td><td>This script needs to be run either manually or by system cron each time a game, or group of 
games are entered. It calculates and ranks the holes in the golfcourses</td></tr>";

//ok, lets find out all the games to tie down to this tournament. We just need to find all games with
//touney=1 and make them unique!

$gametourneysql="select distinct(gameid),date  from games where tournament=1";
$gametourneyquery=mysql_query($gametourneysql);
$gametourneyrow=mysql_fetch_array($gametourneyquery);
$gametourneyexist=mysql_numrows($gametourneyquery); 


echo "<tr>";

echo "<td class=bg0 width=20%><b>Create Tournament</b></td>
<td>This is to create the basic framework for a tournament. To edit, just type in the tourney name and fill in the values. The database will be updated.<p>";

if ($gametourneyexist) {
echo "<form method='post' action='$PHP_SELF' onSubmit='return checkrequired(this)'>";
echo "Tournament Name: <input type='text' maxlength='100' size='50' name='reqtourney_name' value='$reqtourney_name'><p>";

echo "Tournament Game: <select name='gametourneyid'>";
do {
extract($gametourneyrow);
echo "<option value='$gameid'>$gameid</option>";
} while ($gametourneyrow=mysql_fetch_array($gametourneyquery));
echo "</select><p>";

echo "Tournament Type:  <select name='reqtourney_type'>";
echo "<option value='System 36'>System 36</option>";
echo "<option value='Stroke Play (Gross)'>Gross Stroke Play</option>";
echo "<option value='Stroke Play (Net)'>Net Stroke Play</option>";
echo "</select><p>";

echo "Tournament Purse: <input type='text' maxlength='6' size='6' name='reqtourney_purse' value='$reqtourney_purse'><p>";

echo "<input type=\"Submit\" name=\"createtourney\" value=\"Create Tournament\">";



echo "</form>";

} else {
echo "No tournament games to process";
}



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


echo "<tr>";


echo "<td class=bg0 width=20%><b>Process Tournament</b></td><td>This script needs to be run either manually or by system cron each time a tournament is entered. It calculates the ranks of the tournament and populates the tournament tables in the database<p>";
if ($tourneyexist) {
echo "<form method='post' action='tourneycount.php'>";
echo "Select Tournament games: <select name='tourneyid'>";
do {
extract($tourneyrow);
echo "<option value='$tourneyid'>$tourneyid</option>";
} while ($tourneyrow=mysql_fetch_array($tourneyquery));
echo "</select><p>";

echo "Winnings for #1 : <input type='text' maxlength='5' size='5' name='money1' value='0'><br>";
echo "Winnings for #2 : <input type='text' maxlength='5' size='5' name='money2' value='0'><br>";
echo "Winnings for #3 : <input type='text' maxlength='5' size='5' name='money3' value='0'><br>";
echo "Winnings for #4 : <input type='text' maxlength='5' size='5' name='money4' value='0'><br>";
echo "Winnings for #5 : <input type='text' maxlength='5' size='5' name='money5' value='0'><br>";
echo "<input type=\"Submit\" name=\"process\" value=\"Process Tournament\">";



echo "</form>";

} else {
echo "No tournaments to process";
}
echo "</td></tr>";


######################Delete Tourney##########################
//ok, lets find out all the tourneys first
$tourneysql="select tourneyid  from tourney";
$tourneyquery=mysql_query($tourneysql);
$tourneyrow=mysql_fetch_array($tourneyquery);
$tourneyexist=mysql_numrows($tourneyquery); 


echo "<tr>";


echo "<td class=bg0 width=20%><b>Delete Tournament</b></td><td>This deletes the tournament from the database. The games will still remain!<p>";
if ($tourneyexist) {
echo "<form method='post' action='$PHP_SELF'>";
echo "Select Tournament: <select name='tourneyid_del'>";
do {
extract($tourneyrow);
echo "<option value='$tourneyid'>$tourneyid</option>";

} while ($tourneyrow=mysql_fetch_array($tourneyquery));
echo "</select><p>";

echo "<input type=\"Submit\" name=\"deletetourney\" value=\"Delete Tournament\" onclick=\"return confirm('Are you sure you want to delete the tournament?');\">";



echo "</form>";

} else {
echo "No tournaments to process";
}
echo "</td></tr>";



######################Delete Courses##########################
//ok, lets find out all the courses first
$coursedelsql="select *  from courses";
$coursedelquery=mysql_query($coursedelsql);
$coursedelrow=mysql_fetch_array($coursedelquery);
$coursedelexist=mysql_numrows($coursedelquery); 


echo "<tr>";


echo "<td class=bg0 width=20%><b>Delete Course</b></td><td>This deletes the course from the database. This will delete ALL games of ALL players. If there is a tournament, please delete the tourney first.<p>";
if ($coursedelexist) {
echo "<form method='post' action='$PHP_SELF'>";
echo "Select Course: <select name='course_del'>";
do {
extract($coursedelrow);
echo "<option value='$courseid'>$courseid -- $coursename</option>";
} while ($coursedelrow=mysql_fetch_array($coursedelquery));
echo "</select><p>";

echo "<input type=\"Submit\" name=\"deletecourse\" value=\"Delete Course\" onclick=\"return confirm('Are you sure you want to delete the course?');\">";



echo "</form>";

} else {
echo "No courses to process";
}
echo "</td></tr>";


######################Delete Players##########################
//ok, lets find out all the players first
$userdelsql="select *  from users_tour";
$userdelquery=mysql_query($userdelsql);
$userdelrow=mysql_fetch_array($userdelquery);
$userdelexist=mysql_numrows($userdelquery); 


echo "<tr>";


echo "<td class=bg0 width=20%><b>Delete Player</b></td><td>This deletes the players from the database. This will delete ALL games of the selected player. If there is a tournament that the player is in, 
note that the scorecard for that player will no longer be available.<p>";
if ($userdelexist) {
echo "<form method='post' action='$PHP_SELF'>";
echo "Select Player: <select name='user_del'>";
do {
extract($userdelrow);
echo "<option value='$userid'>$userid -- $name $surname</option>";
} while ($userdelrow=mysql_fetch_array($userdelquery));
echo "</select><p>";

echo "<input type=\"Submit\" name=\"deleteuser\" value=\"Delete user\" onclick=\"return confirm('Are you sure you want to delete the user?');\">";



echo "</form>";

} else {
echo "No users to process.";
}
echo "</td></tr>";

######################ADD RAMBLE##########################
//ok, lets find out all the tourneys first
echo "<tr>";


echo "<td class=bg0 width=20%><b>Add Ramble</b></td><td>Add a random ramble. Rambles cannot be deleted as of now, because the algorithm requires a sequential increase in the rambleid. Might change in the future.<p>";

//get dropdown list of users
$namesql="Select * from users_tour ORDER BY userid ASC";

				$namequery=mysql_query($namesql);
				$namerow=mysql_fetch_array($namequery);
				$nameexist=mysql_numrows($namequery);
				

//check latest rambleid

$ramblesql="Select max(rambleid) as rambleid from msgboard";
$ramblequery=mysql_query($ramblesql);
$ramblerow=mysql_fetch_array($ramblequery);

$ramblecurrent=$ramblerow["rambleid"];
$ramblenext=$ramblecurrent+1;


if ($nameexist) {
echo "<form method='post' action='$PHP_SELF'>";
echo "Ramble #$ramblenext) SelectRambler: <select name='rambler_id'>";
do {
extract($namerow);
$fullname=$namerow['name']." ".$namerow['surname'];

echo "<option value='$userid'>$userid -- $fullname </option>";

} while ($namerow=mysql_fetch_array($namequery));

echo "</select>";
echo "<p>";
echo "<TEXTAREA name='reqmsgbody' rows='10' cols='50'>";
echo $reqmsgbody;
echo "</TEXTAREA>";
echo "<p>";
echo "<input type='Hidden' name='ramblenext' value='$ramblenext'>";
echo "<input type='Submit' name='addramble' value='Submit'>";

echo "</form>";

} else {

echo "No users yet in database.";

} //endif nameexist
 

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


#####################END ADD RAMBLE##################


echo "</table>";

} else {


echo "<center>Unauthorized user. Only super user can manage the site.</center>";

}

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