Exemplo n.º 1
0
function displayAllProducts()
{
    $sql = "SELECT productId, productName FROM oe_product";
    $records = fetchAllRecords($sql);
    foreach ($records as $record) {
        echo $record['productName'];
        echo " <a href='updateProduct.php?productId=" . $record['productId'] . "'> Update </a> ";
        echo " <a href='deleteProduct.php'> Delete </a>";
        echo "<br />";
    }
}
Exemplo n.º 2
0
function getProductVolume()
{
    $sql = "SELECT p.productId, p.productName, p.price,\n" . "SUM(qty) AS 'qty', SUM(qty * p.price) AS 'Sales' FROM `oe_orderProduct` op\n" . "RIGHT JOIN `oe_product` p\n" . "ON op.productId = p.productId\n" . "GROUP BY `productId`\n" . "ORDER BY Sales DESC";
    uiGetProductVolume(fetchAllRecords($sql));
}
Exemplo n.º 3
0
function getCategories()
{
    $sql = "SELECT `categoryId`, `categoryName` \n" . "FROM `oe_category`\n";
    uiGetCategories(fetchAllRecords($sql));
}
Exemplo n.º 4
0
if (isset($_GET['searchText']) && $_GET['searchText'] != NULL) {
    $field = $_GET['searchBy'];
    // using $field IS NOT SAFE... :field not working. -- fix
    $query .= " WHERE LCASE({$field}) = LCASE(:value)";
    $searchParams[':value'] = $_GET['searchText'];
}
// Set order -- params not working
if (isset($_GET['order'])) {
    $query .= " ORDER BY " . $_GET['order'];
    // $searchParams[':order'] = $_GET['order'];
}
// // Debug
// echo "DEBUG ------- <br> QUERY: " . $query . "<br>";
// print_r($searchParams);
// echo "<br>---------";
$results = fetchAllRecords($query, $searchParams);
// If query produces results
if (isset($results[0])) {
    ?>
        <th>Number</th>
        <th>Make</th>
        <th>Model</th>
        <th>Owner</th>

        <?php 
    //Print results
    foreach ($results as $row) {
        echo "<tr><td>" . $row['nNumber'] . "</td><td>" . $row['make'] . "</td><td>" . $row['model'] . "</td><td>" . $row['airlineId'] . "</td></tr>";
    }
} else {
    echo "<h4>Sorry, a matching airline could not be found</h4>";
Exemplo n.º 5
0
if (isset($results[0])) {
    ?>
        <th>ID</th>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Date of Birth</th>
        <th>Phone</th>
        <th>Email</th>
        <th>Scheduled Flights</th>
        <th>Updated</th>

        <?php 
    //Print results
    foreach ($results as $row) {
        $query = "SELECT count(*) FROM passengerFlights\n          WHERE passengerId = " . $row['passengerId'];
        $flightCount = fetchAllRecords($query);
        echo "<tr><td class='passengerId'>" . $row['passengerId'] . "</td><td class='firstName'>" . $row['first'] . "</td><td class='lastName'>" . $row['last'] . "</td><td>" . $row['dob'] . "</td><td>" . $row['phone'] . "</td><td>" . $row['email'] . "</td><td>" . $flightCount[0]['count(*)'] . "</td><td>" . $row['updated'] . "</td></tr>";
    }
} else {
    echo "<h4>Sorry, a matching airline could not be found</h4>";
}
?>
    </table>

    <div id="ajaxResult">

    </div>
  </div>

</body>
</html>
Exemplo n.º 6
0
      <?php 
    foreach ($results as $result) {
        $diff = substr($result['timeDifference'], 1, 5);
        echo "<tr><td>" . $result['flightId'] . "</td><td>" . $result['number'] . "</td><td>" . $result['airlineId'] . "</td><td>" . $result['aircraftNumber'] . "</td><td>" . $result['departurePort'] . "</td><td>" . $result['arrivalPort'] . "</td><td>" . ($dept = substr($result['departureTime'], 11, 5) . "</td><td>" . ($arriv = substr($result['arrivalTime'], 11, 5) . "</td><td>" . $diff . "</td><td>" . $result['updated'] . "</td></tr>"));
    }
} else {
    echo "<h4>No flights scheduled for this day.</h4>";
}
?>
    </table>

    <?php 
if (isset($results[0])) {
    $maxQuery = "SELECT max(timediff(arrivalTime, departureTime)), number FROM flight\n        WHERE substring(departureTime, 1, 10) = :departDay";
    $minQuery = "SELECT min(timediff(arrivalTime, departureTime)), number FROM flight\n        WHERE substring(departureTime, 1, 10) = :departDay";
    $avgQuery = "SELECT avg(timediff(arrivalTime, departureTime)), number FROM flight\n        WHERE substring(departureTime, 1, 10) = :departDay";
    $par[':departDay'] = $searchParams[':departDay'];
    $max = fetchAllRecords($maxQuery, $par);
    $min = fetchAllRecords($minQuery, $par);
    $avg = fetchAllRecords($avgQuery, $par);
    echo "<h4>Longest flight duration: " . $max[0]['number'] . "</h4>";
    echo "<h4>Shortest flight duration: " . $min[0]['number'] . "</h4>";
    echo "<h4>Average flight duration: " . $avg[0]['number'] . "</h4><br>";
}
?>

  </div>

</body>
</html>
Exemplo n.º 7
0
<?php

include "../../includes/genericDataAccess.inc.php";
$query = "SELECT flight.* FROM passengerFlights\n  LEFT JOIN flight ON passengerFlights.flightId = flight.flightId\n  WHERE passengerId = :id ";
$params[':id'] = $_GET['id'];
$results = fetchAllRecords($query, $params);
//$current = current($result);
if (isset($results[0])) {
    echo "<table>\n    <th>Flight ID</th>\n    <th>Number</th>\n    <th>Airline ID</th>\n    <th>Aircraft Number</th>\n    <th>Departure Port</th>\n    <th>Arrival Port</th>\n    <th>Departure time</th>\n    <th>Arrival Time</th>\n    <th>Updated</th>\n    <tr>\n    ";
    foreach ($results as $result) {
        echo "<tr>";
        foreach ($result as $r => $value) {
            echo "<td>" . $value . "</td>";
            // echo "<tr><td>" . $r['flightId'] .
            // "</td><td>" . $r['updated'] . "</td></tr>";
        }
        echo "</tr>";
    }
}