-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgetYears.php
More file actions
114 lines (95 loc) · 2.72 KB
/
getYears.php
File metadata and controls
114 lines (95 loc) · 2.72 KB
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
106
107
108
109
110
#!/usr/local/bin/php
<?php
$connection = oci_connect($username = 'weingart',
$password = 'bridgeoverlord201',
$connection_string = '//oracle.cise.ufl.edu/orcl');
if (!$connection) {
die('Could not connect');
}
// Retrieve data from Query String
$sport = $_GET['sport'];
$playertype = $_GET['playertype'];
// Escape User Input to help prevent SQL Injection
//$sport = mysql_real_escape_string($sport);
if ($sport == 'Baseball')
{
if($playertype == 'Team')
{
$query = "SELECT DISTINCT year FROM BaseballTeams ORDER BY year";
}
if($playertype == 'Pitcher')
{
$query = "SELECT DISTINCT year FROM BaseballPitching ORDER BY year";
}
if($playertype == 'Position Player Batting')
{
$query = "SELECT DISTINCT year FROM BaseballBatting ORDER BY year";
}
if($playertype == 'Position Player Fielding')
{
$query = "SELECT DISTINCT year FROM BaseballFielding ORDER BY year";
}
if($playertype == 'Manager')
{
$query = "SELECT DISTINCT year FROM BaseballManagers ORDER BY year";
}
}
else if ($sport == 'Basketball')
{
if($playertype == 'Team')
{
$query = "SELECT DISTINCT year FROM BasketballTeams ORDER BY year";
}
if($playertype == 'Coach')
{
$query = "SELECT DISTINCT year FROM BasketballCoaches ORDER BY year";
}
if($playertype == 'Player')
{
$query = "SELECT DISTINCT year FROM BasketballPlayers ORDER BY year";
}
}
else if ($sport == 'Hockey')
{
if($playertype == 'Team')
{
$query = "SELECT DISTINCT year FROM HockeyTeams ORDER BY year";
}
if($playertype == 'Coach')
{
$query = "SELECT DISTINCT year FROM HockeyCoaches ORDER BY year";
}
if($playertype == 'Position Player')
{
$query = "SELECT DISTINCT year FROM HockeyScoring ORDER BY year";
}
if($playertype == 'Goalie')
{
$query = "SELECT DISTINCT year FROM HockeyGoalies ORDER BY year";
}
}
$statement = oci_parse($connection, $query);
$statement2 = oci_parse($connection, $query);
oci_execute($statement);
oci_execute($statement2);
echo "Select beginning year: ";
echo '<select name="begYear" id = "year1">';
echo '<option value = "-1">Select:</option>';
while($row=oci_fetch_assoc($statement)) {
echo '<option value="' . $row['YEAR'] . '">' . $row['YEAR'] .'</option>';
}
echo "</select> \n";
echo "Select end year: ";
echo '<select name="endYear" id = "year2">';
echo '<option value = "-1">Select:</option>';
while($row=oci_fetch_assoc($statement2)) {
echo '<option value="' . $row['YEAR'] . '">' . $row['YEAR'] .'</option>';
}
echo "</select> \n";
//
// VERY important to close Oracle Database Connections and free statements!
//
oci_free_statement($statement);
oci_free_statement($statement2);
oci_close($connection);
?>