Last active
August 29, 2015 14:04
-
-
Save mduleone/aa7558e5ad886a48942c to your computer and use it in GitHub Desktop.
Original update query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$updQuery = "UPDATE currentQueue SET "; | |
if (isset($_GET["arrive"]) && $_GET["arrive"] != "") { | |
$updQuery .= "arrive=" . $arrive; | |
} | |
if (isset($_GET["depart"]) && $_GET["depart"] != "") { | |
if (isset($_GET["arrive"]) && $_GET["arrive"] != "") { | |
$updQuery .= ", "; | |
} | |
$updQuery .= "depart=" . $depart; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$db_params = new stdClass(); | |
$db_params->host = "localhost"; | |
$db_params->user = "Matt"; | |
$db_params->pass = ""; | |
$db_params->database = "parks"; | |
$db = new mysqli($db_params->host, | |
$db_params->user, | |
$db_params->pass, | |
$db_params->database); | |
if (mysqli_connect_errno()) { | |
die("Failed to connect to MySQL: " . $db->error); | |
} | |
if(!isset($_GET["id"]) || $_GET["id"] == "") { | |
die("Missing id GET param."); | |
} else{ | |
$id = $_GET["id"]; | |
} | |
if((!isset($_GET["arrive"]) || $_GET["arrive"] == "") && (!isset($_GET["depart"]) || $_GET["depart"] == "")) { | |
die("Missing arrive and depart GET params."); | |
} else{ | |
if (isset($_GET["arrive"]) && $_GET["arrive"] != "") { | |
$arrive = $_GET["arrive"]; | |
} | |
if (isset($_GET["depart"]) && $_GET["depart"] != "") { | |
$depart = $_GET["depart"]; | |
} | |
} | |
$updQuery = "UPDATE currentQueue SET "; | |
if (isset($_GET["arrive"]) && $_GET["arrive"] != "") { | |
$updQuery .= "arrive=" . $arrive; | |
if (isset($_GET["depart"]) && $_GET["depart"] != "") { | |
$updQuery .= ", depart=" . $depart; | |
} | |
} else if (isset($_GET["depart"]) && $_GET["depart"] != "") { | |
$updQuery .= "depart=" . $depart; | |
} | |
$updQuery .= " WHERE id=" . $_GET["id"]; | |
$stmt = $db->prepare($delQuery); | |
$execOutput = $stmt->execute(); | |
$stmt->close(); | |
$db->close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment