示例#1
0
function getPaymentMethodFromOrderId($connection, $order_id)
{
    $query = "SELECT card_number, card_company" . " FROM payments NATURAL JOIN orders WHERE order_id = {$order_id};";
    $results = mysql_query($query, $connection);
    if (!$results) {
        die("Could not get payment methods." . mysql_error());
    }
    $row = mysql_fetch_assoc($results);
    return composePaymentMethod($row['card_company'], $row['card_number']);
}
示例#2
0
function getPaymentMethodFromCardNumber($connection, $card_number)
{
    $query = "SELECT card_company" . " FROM payments WHERE card_number = {$card_number};";
    $results = mysql_query($query, $connection);
    if (!$results) {
        die("Could not get payment methods." . mysql_error());
    }
    $row = mysql_fetch_assoc($results);
    return composePaymentMethod($row['card_company'], $card_number);
}
示例#3
0
function showResults($results)
{
    if (!$results) {
        die('Could not get search result: ' . mysql_error());
    }
    echo "<h2>Search Results</h2>";
    $num_rows = mysql_num_rows($results);
    if ($num_rows == 0) {
        echo "\n        <p class='center'>\n        There are no orders found. Please revise your criteria and try again.\n        </p>";
        return;
    }
    echo "\n      <table>\n      <tr>\n      <th>Order ID</th>\n      <th>Customer ID</th>\n      <th>Payment Method</th>\n      <th>Shipping Method</th>\n      <th>Date</th>\n      </tr>";
    while ($row = mysql_fetch_assoc($results)) {
        $payment_method = composePaymentMethod($row['card_company'], $row['card_number']);
        echo "\n    <tr>\n      <td>\n      <a href='show_order.php?order_id={$row['order_id']}'>\n      {$row['order_id']}\n      </a>\n      </td>\n      <td>{$row['customer_id']}</td>\n      <td>{$payment_method}</td>\n      <td>{$row['shipping_method']}</td>\n      <td>{$row['order_date']}</td>\n    </tr>";
    }
    echo "</table>";
    if ($num_rows == 1) {
        echo "<p class='center'>Found 1 order.</p>";
    } else {
        echo "<p class='center'>Found {$num_rows} orders.</p>";
    }
}