-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteamQuery.php
More file actions
50 lines (42 loc) · 2.19 KB
/
teamQuery.php
File metadata and controls
50 lines (42 loc) · 2.19 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
<?php
/*
** teamQuery.php
** Author: Peter DiSalvo
** Date: 12/14/2012
** Query teams with criteria.
*/
require_once('config.inc.php');
// Get form values
$teamName = !empty($_GET['teamName']) ? "'". $_GET['teamName'] ."'" : "NULL";
$city = !empty($_GET['city']) ? "'".$_GET['city']."'" : "NULL";
$stateAbbreviation = !empty($_GET['state']) && $_GET['state'] != '--' ? "'". $_GET['state'] ."'" : "NULL";
$genderID = !empty($_GET['gender']) && $_GET['gender'] != '--' ? "'" . $_GET['gender'] . "'" : "NULL";
$sportID = !empty($_GET['sport']) && $_GET['sport'] != '--' ? $_GET['sport'] : "NULL";
$skillLevelID = !empty($_GET['skillLevel']) && $_GET['skillLevel'] != '--' ? $_GET['skillLevel'] : "NULL";
$leagueName = !empty($_GET['leagueName']) && $_GET['leagueName'] != '--' ? "'". $_GET['leagueName'] ."'" : "NULL";
$hasTryouts = !empty($_GET['hasTryouts']) && $_GET['hasTryouts'] != '--' ? $_GET['hasTryouts'] : "NULL";
$hasLeagueDues = !empty($_GET['hasLeagueDues']) && $_GET['hasLeagueDues'] != '--' ? $_GET['hasLeagueDues'] : "NULL";
$ageMin = !empty($_GET['ageMin']) && $_GET['ageMin'] != '--' ? $_GET['ageMin'] : "NULL";
$ageMax = !empty($_GET['ageMax']) && $_GET['ageMax'] != '--' ? $_GET['ageMax'] : "NULL";
$lookingStatus = !empty($_GET['lookingStatus']) && $_GET['lookingStatus'] != '--' ? $_GET['lookingStatus'] : "NULL";
$lookingPosition = !empty($_GET['position']) && $_GET['position'] != '--' ? $_GET['position'] : "NULL";
// Open database connection
$mysqliConnection = new mysqli(Config::DB_CONN, Config::DB_USER, Config::DB_PASS, Config::DB_NAME);
if (mysqli_connect_error())
{
die(Config::DB_ERROR_TEXT . mysqli_connect_errno() . ' ' . mysqli_connect_error());
}
$queryString = <<<SQL
CALL teamSearch($teamName, $city, $stateAbbreviation, $genderID, $sportID, $skillLevelID, $leagueName, $hasTryouts,
$hasLeagueDues, $ageMin, $ageMax, $lookingStatus, $lookingPosition);
SQL;
$teamsResultSet = $mysqliConnection->query($queryString) or die($mysqliConnection->error);
$teams = array();
while($teamRecord = $teamsResultSet->fetch_array(MYSQLI_ASSOC))
{
$teams[] = $teamRecord;
}
$teamsResultSet->free();
$mysqliConnection->close();
require_once Config::CTMP_QRY_TEAM;
?>