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

include("dbasecon.inc.php");

include("session.inc.php");

include ("header.php");

include ("statscoursefunctions.inc.php");







//get list of players



$usersql="select * from users_tour  

					order by name ASC";


				$userquery=mysql_query($usersql);

				$userrow=mysql_fetch_array($userquery);

				$userexist=mysql_numrows($userquery);





?>



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



<? showheader("View Players"); ?>



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



<b class="error">Click on the player for details.</b><p>









<u><b>Registered Players: <? echo $userexist; ?></b></u>



<p>

<?

if ($userexist) {



?>



<table border=1>

<tr class="menu-bg">

<td>Player</td><td>Handicap</td><td>Age</td><td>Home Club</td><td>Email</td><td>Contact</td>

<td>Avg.Gross</td><td>Avg.Net</td><td>Rounds</td>





</tr>









<?







//OK, populate the drop down on the row.

do {





extract($userrow);



//get how many rounds player played

$roundchecksql="select * from games

								 where userid='$userid'";

				$roundcheckquery=mysql_query($roundchecksql);

				$roundcheckrow=mysql_fetch_array($roundcheckquery);

				$roundcheckexist=mysql_numrows($roundcheckquery);



//lets start getting the average and stuff for player





do {

$gross_score=$roundcheckrow['gross_score'];

$net_score=$roundcheckrow['net_score'];





$total_gross=$total_gross+$gross_score;

$total_net=$total_net+$net_score;



} while ($roundcheckrow=mysql_fetch_array($roundcheckquery));



if ($roundcheckexist) {

$avg_gross=number_format(($total_gross/$roundcheckexist),2,'.','');

$avg_net=number_format(($total_net/$roundcheckexist),2,'.','');

} else {

$avg_gross="na";

$avg_net="na";

}

echo "<tr><td class='menu-bg2' valign=center><a href='players2.php?userid=$userid&action=details&fullname=$name $surname'>$name $surname</a></td><td>$handicap</td>

<td>$age</td><td>$homeclub</td><td><a href='mailto:$email'>$email</a></td><td>$phoneno</td><td>$avg_gross</td>";

echo "<td>$avg_net</td><td>$roundcheckexist</td>";

echo "</tr>";



$total_gross=0;

$total_net=0;

																																															

}while ($userrow=mysql_fetch_array($userquery));

 //endwhile





echo "</table>";

















} else {



echo "<b>There are no players available.</b>"; 

}

?>







<? showfooter(); ?>

Return current item: GolfstatsPHP