0

我正在构建一个机场出租车预订系统,作为包含预订的表格的一部分,有以下列以及本示例不需要的其他数据:

Customer Name 
Outbound_date
Outbound_time
Outbound_pickup
Outbound_destination

Inbound_date
Inbound_time
Inbound_pickup
Inbound_destination

我正在构建一个页面,显示用户输入的两个日期之间的所有预订,然后将结果显示在 HTML 表格中,标题如下:姓名、取货、目的地、日期、时间。

我想做的是建立一个 if 语句,询问入境或出境日期是否最近,然后显示旅程信息。我需要所有这些都在 HTML 表的循环中。

我大致假设该声明会询问是否outbound_date<inbound_date echo outbound_destination等...否则echo inbound_destination等...

这是我选择数据并显示它的代码,但是它当前选择 outbound_pickup/destination/date 和入站版本。我想要做的只是显示出站/入站列,这取决于用户提交的两个日期之间。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Computerised Booking System | Airport Hopper</title>
    <meta name="generator" content="TextMate http://macromates.com/">
    <meta name="author" content="Daniel Green">
    <link rel="stylesheet" type="text/css" href="../css/main.css"/>
    <!-- Date: 2012-02-27 -->
</head>
<body>
<div id="wrapper">
<?php include('../includes/header.php');?>
<?php include('../includes/cbs_sidebar.php');?>

<div class="main-container">
<h2>Airport Hopper CBS</h2><hr/>
<?php
$db_host = 'ahopperintranet.db.8239985.hostedresource.com';
$db_user = 'ahopperintranet';
$db_pwd = '******';

$database = 'ahopperintranet';
$table = 'bookings';

if (!mysql_connect($db_host, $db_user, $db_pwd))
    die("Can't connect to database");

if (!mysql_select_db($database))
    die("Can't select database");

// sending query
$result = mysql_query("SELECT booking_ref, customer_name, outbound_destination, outbound_date, outbound_time, inbound_date FROM {$table} ORDER BY GREATEST(outbound_date, inbound_date)");
if (!$result) {
    die("Query to show fields from table failed");
}

$fields_num = mysql_num_fields($result);

echo "<table border='1'><tr>";
 ?>


<tr>
    <td>Booking Ref</td>
    <td>Customer Name</td>
    <td>Pickup</td>
            <td>Destination</td>
            <td>Date</td>
            <td>Time</td>

</tr>

<?php
// printing table rows
while($row = mysql_fetch_row($result))
{
    echo "<tr>";

    // $row is array... foreach( .. ) puts every element
    // of $row to $cell variable
    foreach($row as $cell)
        echo "<td>$cell</td>";

    echo "</tr>\n";
}
mysql_free_result($result);
?>
<div class="clear"></div>
</body>
4

0 回答 0