-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayerQuery.php
More file actions
43 lines (35 loc) · 1.54 KB
/
Copy pathplayerQuery.php
File metadata and controls
43 lines (35 loc) · 1.54 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
<?php
/*
** playerQuery.php
** Author: Peter DiSalvo
** Date: 12/14/2012
** Search for players with given criteria.
*/
require_once('config.inc.php');
// Get form values
$playerLastName = !empty($_GET['playerLastName']) ? "'". $_GET['playerLastName'] ."'" : "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";
$positionID = !empty($_GET['position']) && $_GET['position'] != '--' ? $_GET['position'] : "NULL";
$lookingStatus = !empty($_GET['lookingStatus']) && $_GET['lookingStatus'] != '--' ? $_GET['lookingStatus'] : "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 playerSearch($playerLastName, $city, $stateAbbreviation, $genderID, $sportID, $positionID, $lookingStatus);
SQL;
$playersResultSet = $mysqliConnection->query($queryString) or die($mysqliConnection->error);
$players = array();
while($playerRecord = $playersResultSet->fetch_array(MYSQLI_ASSOC))
{
$players[] = $playerRecord;
}
$playersResultSet->free();
$mysqliConnection->close();
require_once Config::CTMP_QRY_PLAYER;
?>