-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalcStats.php
105 lines (99 loc) · 3.64 KB
/
calcStats.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<html>
<head>
<?php include "initialize.php"; ?>
<?php
$amount = $_POST['amount'];
//echo 'amount = '.$amount."</br>";
$qry = "select * from players where TDs >$amount";
// echo $qry."</br>";
$result = mysqli_query($db, $qry);
//while($players = mysqli_fetch_assoc($result)){
// echo $players['playerName'].$players["TDs"];
// }
?>
<?php
$user = $_SESSION['userName'];
$userID = $_SESSION['userID'];
$qry = "select * from team where userID = '$userID'";
$result = mysqli_query($db, $qry);
$leagueCount = mysqli_num_rows($result);
$leagues = array();
$index = 0;
while($row = mysqli_fetch_assoc($result)){
$leagues[$index] = $row['leagueid'];
$index++;
}
if(!isset($_SESSION['userName'])){
//session was not set correctly, user is redirected to the main page
header("location:/index.php");
}
?>
<title><?php echo $user; ?></title>
<?php include "initStyles.php"; ?>
<script>
$(document).ready(function(){
$("#mydiv").hide();
$("#btn2").hide();
$("#stats").show();
$("#btn1").click(function(){
$("#mydiv").show();
$("#btn2").show();
$("#btn1").hide();
});
$("#btn2").click(function(){
$("#mydiv").hide();
$("#btn2").hide();
$("#btn1").show();
});
$("#btn3").click(function(){
$("#stats").show();
});
});
</script>
</head>
<body>
<div id="login_success_content">
<h1 class="whiteText">logged in as: <?php echo $user; ?></h1>
<h2 class="whiteText">Leauge: <?php
for($i=0;$i<$leagueCount;$i++) {
if($i+1 == $leagueCount){
echo $leagues[$i];
}
else{
echo $leagues[$i].', ';
}
} ?></h2>
<button id="btn1" class="btn btn-primary">Display my team</button>
<button id="btn2" class="btn btn-primary">Hide my team</button>
<a href="../functions/addPlayer.php" class="btn btn-primary">Add player</a>
<div id='mydiv'>
</br>
<a href="../functions/updateTeamName.php" class="btn btn-primary">Update Team Name</a>
<?php include '../tables/playerSetTable.php'; ?>
<?php
// include '../allstars.php';
?>
</div>
</br>
<!--<button id="btn3" class="btn btn-primary">Stats</button>-->
<a href="login/login_success.php" id="goBack" class="btn btn-primary">Go Back</a>
<div id="stats">
<table id="statsTable">
<tr>
<th>Player</th>
<th>TouchDowns</th>
</tr>
<?php
$amount = $_POST['amount'];
$qry = "select * from players where TDs >$amount";
$result = mysqli_query($db, $qry);
while($players = mysqli_fetch_assoc($result)){
echo "<tr><td>".$players['playerName']."</td><td>".$players["TDs"]."</td></tr>";
}
?>
</table>
</div>
<a href="logout.php" class="btn btn-primary">Log out</a>
</div>
</body>
</html>