Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "nitroxtech.c48qi7cc3kyh.us-west-1.rds.amazonaws.com";
- $username = "NitroxAdmin";
- $password = "5tgjkl123";
- // Create connection
- $conn = new mysqli($servername, $username, $password, "StorageDBWebAppMainDatabase");
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT dateCreated FROM FacilitiesUnitsHistory WHERE facilityId=" . htmlspecialchars($_GET["facilityId"]) . " AND unitId=" . htmlspecialchars($_GET["unitId"]) . " ORDER BY dateCreated ASC";
- $facilityToUnits = $conn->query($sql);
- $dateCreatedArray = array();
- $rateAmountArray = array();
- $rowArray = array();
- if ($facilityToUnits->num_rows > 0) {
- // output data of each row
- while($row = $facilityToUnits->fetch_assoc()) {
- array_push($rateAmountArray, $row['rateAmount']);
- array_push($dateCreatedArray, $row['dateCreated']);
- }
- } else {
- echo "0 results";
- }
- $sql = "SELECT dateCreated FROM FacilitiesUnits WHERE facilityId=" . htmlspecialchars($_GET["facilityId"]) . " AND unitId=" . htmlspecialchars($_GET["unitId"]);
- $facilityToUnits = $conn->query($sql);
- if ($facilityToUnits->num_rows > 0) {
- // output data of each row
- while($row = $facilityToUnits->fetch_assoc()) {
- array_push($rateAmountArray, $row['rateAmount']);
- array_push($dateCreatedArray, $row['dateCreated']);
- }
- } else {
- echo "0 results";
- }
- for ($x = 0; $x < count($dateCreatedArray); $x++) {
- $rowArray[$x]['dateCreated'] = $dateCreatedArray[$x];
- $rowArray[$x]['rateAmount'] = $rateAmountArray[$x];
- }
- echo json_encode($rowArray);
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement