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

而不是“如果($return_date!= $null_date){”,使用:

if (strtotime($return_date) > 0) {

我还希望“jobs”表中的“booking_ref”列没有与之关联的唯一索引。

于 2013-01-14T07:20:39.813 回答