0

最初に顧客の連絡先と請求の詳細などを保存する予約を作成する予約システム(空港タクシー会社)を作成しています。次に、IDを使用して旅の情報を別のテーブルに投稿し、返品の詳細が含まれている場合は別のテーブルを作成します復路と同じ JOBS テーブルに記録します。IF ステートメントを使用して、返品の詳細が送信されているかどうかを確認しています。ただし、最初の旅だけを挿入し、帰りは挿入しません。以下のコードを参照してください。

何か案は?

また、結果を達成するために奇妙な方法をとっている可能性が高いことも理解しています。そのため、批判や指摘も歓迎します。

ありがとう

<?php


$customer_title          =  $_POST['customer_title'];
$customer_first_name     =  $_POST['customer_first_name'];
$customer_last_name      =  $_POST['customer_last_name'];
$billing_address         =  $_POST['billing_address'];
$customer_tel            =  $_POST['customer_tel'];
$customer_mobile         =  $_POST['customer_mobile'];
$customer_email          =  $_POST['customer_email'];
$passengers              =  $_POST['passengers'];
$cases                   =  $_POST['cases'];
$return_flight_number    =  $_POST['return_flight_number'];
$price                   =  $_POST['price'];
$pickup_date             =  $_POST['pickup_date'];
$pickup_time             =  $_POST['pickup_time'];
$pickup_address          =  $_POST['pickup_address'];
$pickup_destination      =  $_POST['pickup_destination'];
$return_date             =  $_POST['return_date'];
$return_time             =  $_POST['return_time'];
$return_pickup           =  $_POST['return_pickup'];
$return_destination      =  $_POST['return_destination'];
$booking_notes           =  $_POST['booking_notes'];

$booking_status          =  Confirmed;
$account_number          =  9999;
$authorised              =  N;


$booking_date            = 0;
$null_date               = '0000-00-00'; 


include('../assets/db_connection.php');

mysql_select_db("airporthopper");

mysql_query("INSERT INTO bookings(customer_name, billing_address, account_number, contact_tel, contact_mob, contact_email,
            party_pax, party_cases, booking_notes, price, booking_agent, booking_date, booking_status, authorised)
VALUES('$customer_title $customer_first_name $customer_last_name', '$billing_address', $account_number, '$customer_tel', '$customer_mobile', '$customer_email', '$passengers', '$cases', '$booking_notes', '$price', 'Danny Green', '$booking_date',
    '$booking_status', '$authorised'   )");



$booking_ref = mysql_insert_id();

mysql_query("INSERT INTO jobs(booking_ref, pickup_date, pickup_time, pickup_address, destination_address, scheduled)VALUES('$booking_ref', '$pickup_date', '$pickup_time', '$pickup_address', '$pickup_destination', 'N')");

if ($return_date != $null_date) {
mysql_query("INSERT INTO jobs(booking_ref, pickup_date, pickup_time, pickup_address, destination_address, return, scheduled)VALUES('$booking_ref', '$return_date', '$return_time', '$return_pickup', '$return_destination', 'Y' , 'N')");
 }




?> 
4

1 に答える 1

0

「if ($return_date != $null_date) {」の代わりに、次を使用します。

if (strtotime($return_date) > 0) {

また、「jobs」テーブルの「booking_ref」列に一意のインデックスが関連付けられていないことを願っています。

于 2013-01-14T07:20:39.813 に答える