0

我正在尝试为我的快递公司创建一个基本的货运跟踪页面。用户将提供参考号,并且需要查询以从两个表中提取不同列中的数据。下面是 HTML 代码,下面是 php 代码。HTML 工作正常,但是当我提交表单时,php 会抛出一个空白页。谁能告诉我我在这里犯了什么错误。在此先感谢您的帮助。

HTML 代码:

<form action="tracking.php" method="POST" id="insert">
<table>
<tr>
<td>Please enter your 9 digit Docket No:</td>
<td><input type="text" size=9 name="docketno"></td>
</tr>
<tr>
<td colspan=2 id="sub"><input type="submit"onClick="confSubmit(this.form);" name="submit" value="submit" >&nbsp;&nbsp;<input type="reset" value="Reset!"></td>
</tr></Table></form>

PHP代码:

<?php

// contact to database

$connect = mysql_connect('localhost', 'userid', 'password') or die ("Error , check your server connection.");

mysql_select_db("testing", $connect);



//Get data in local variable

$_docketno=$_POST['docketno'];


// check for null values

if ($_docketno=="")

echo "Docket Number must be entered, please hit back button and re-enter Docket Number";

else{

$query = "SELECT shipment_data.docketno, shipment_data.bookingdatetime, shipment_data.customercode, shipment_data.shippername, shipment_data.bookingou, shipment_data.assureddeliverydate, for_delivery_details.deliverydatetime, for_delivery_details.deliverystatus, for_delivery_details.name_and_number_of_the_person_to_whom_del, for_delivery_details.deliveryattemptnumber_1, for_delivery_details.deliveryattemptnumber_2, for_delivery_details.deliveryattemptnumber_3, for_delivery_details.faileddel.attempt,reason_1, for_delivery_details.faileddel.attempt,reason_2, for_delivery_details.faileddel.attempt,reason_3 "
 "FROM shipment_data LEFT JOIN for_delivery_details where docketno=".$_POST['docketno'].
    "ON shipment_data.docketno = for_delivery_details.docketno"; 

$result = mysql_query($query) or die(mysql_error());

// Print out the contents of each row into a table 
while($row = mysql_fetch_array($result)){
    echo Docket Number          " - ". $row[docketno];  
    echo Booking Date Time          " - ". $row[bookingdatetime];
    echo Customer Code          " - ". $row[customercode];
    echo Shipper Name           " - ". $row[shippername];
    echo Booked From            " - ". $row[bookingou];
    echo Assured Delivery Date      " - ". $row[assureddeliverydate];
    echo Delivery Date Time         " - ". $row[deliverydatetime];
    echo Delivery Status            " - ". $row[deliverystatus];
    echo Name Number to whom delivered  " - ". $row[name_and_number_of_the_person_to_whom_del];
    echo First Delivery attempt date    " - ". $row[deliveryattemptnumber_1];
    echo Second Delivery attempt date   " - ". $row[deliveryattemptnumber_2];
    echo Third Delivery attempt date    " - ". $row[deliveryattemptnumber_3];
    echo First delivery, fail reason    " - ". $row[faileddel.attempt,reason_1];
    echo Second delivery, fail reason   " - ". $row[faileddel.attempt,reason_2];
    echo Third delivery, fail reason    " - ". $row[faileddel.attempt,reason_3];

}
?>

MySql 表:

create table if not exists `shipment_data` (
  `docketno` int(11) not null,
  `referenceno` int(11) default null,
  `bookingdatetime` datetime not null,
  `customercode` int(11) not null default '9999',
  `shippername` varchar(100) not null,
  `shipperaddress` varchar(255) not null,
  `shipperphone` varchar(12) not null comment 'no special characters like (,),+',
  `shipperemail` varchar(50) null default '@',
  `consigneename` varchar(100) not null,
  `consigneeaddress` varchar(255) not null,
  `consigneephone` varchar(12) not null comment 'no special characters like (,),+',
  `consigneeemail` varchar(50) null default '@',
  `bookingou` varchar(20) not null,
  `deliveryou` varchar(20) not null,
  `assureddeliverydate` date not null,
  `numberofpackages` int(9) not null default '1',
  `firststickernum` int(11) not null,
  `laststickernum` int(11) not null,
  `packagedetails` enum('documents','carton box','gunny bag','wooden box','plastic bag') not null,
  `goodstypecode` int(6) not null,
  `goodsdescription` varchar(255) not null,
  `goodsvalue` decimal(10,0) not null,
  `freestoragedays` smallint(6) not null default '1',
  `customerinvoiceno` varchar(100) default null,
  `waybillnumber` varchar(100) default null,
  `servicecode` varchar(255) not null,
  `servicedetails` varchar(255) not null,
  `riskcoverage` enum('shipper risk','carrier risk') not null,
  `length_inches` decimal(10,2) not null default '1.00',
  `breadth_inches` decimal(10,2) not null default '1.00',
  `height_inches` decimal(10,2) not null default '1.00',
  `volumetricweight` double not null comment '((length x breadth x height)/1728)x10',
  `actualweight_kg` decimal(10,2) not null default '0.10',
  `chargedweight_kg` decimal(10,2) not null default '0.10',
  `totalcharge` decimal(10,2) not null default '1.00',
  `arrivaldateatdel_ou` datetime default null,
  `movementstatus` enum('','in-transit','reached') default null,
  `movementid` varchar(75) default null,
  primary key (`docketno`)
) engine=innodb default charset=utf8;


create table if not exists `for_delivery` (
  `docketno` int(11) not null,
  `assureddeliverydate` date not null,
  `deliverydatetime` datetime null,
  `deliverystatus` enum('','taken for delivery','delivered','undelivered','partial delivery') not null,
  `undeliveredfor18hrs_reason` tinytext null,
  `adicode` varchar(20) not null,
  `adiname` varchar(100) not null,
  `adinumber` int(11) not null,
  `deliveryattemptnumber_1` datetime null,
  `faileddel_attempt_reason_1` varchar(255) null,
  `deliveryattemptnumber_2` datetime null,
  `faileddel_attempt_reason_2` varchar(255) null,
  `deliveryattemptnumber_3` datetime null,
  `faileddel_attempt_reason_3` varchar(255) null,
  `name_and_number_of_the_person_to_whom_del.` varchar(255) null,
  `if_not_the_named_person,_upload_copy_of_identity_proof` blob null,
  `first_noticedate` date null,
  `first_noticenum` int(11) null comment 'after non-delivery 6 days of arrival at ou',
  `second_noticedate` date null,
  `second_noticenum` int(11) null comment 'after non-delivery 15 days of arrival at ou',
  `third_noticedate` date null,
  `third_noticenum` int(11) null comment 'for auction/disposal intimation after non-delivery 30 days of arrival at ou',
  primary key(docketno),
  foreign key (docketno) references shipment_data(docketno) on delete cascade
) engine=innodb default charset=utf8;
4

1 回答 1

0

尝试这个:

if ($_POST['docketno'] == ""){

   echo "Docket Number must be entered, please hit back button and re-enter Docket Number";
}

else{

   $query = "SELECT * FROM shipment_data LEFT JOIN for_delivery_details ON shipment_data.docketno = for_delivery_details.docketno where docketno=".$_POST['docketno']; 

   $result = mysql_query($query) or die(mysql_error());

   // Print out the contents of each row into a table 
   while($row = mysql_fetch_array($result))
   {
       echo "Docket Number           - ". $row[docketno];  
       echo "Booking Date Time           - ". $row[bookingdatetime];
       echo "Customer Code           - ". $row[customercode];
       echo "Shipper Name            - ". $row[shippername];
       echo "Booked From             - ". $row[bookingou];
       echo "Assured Delivery Date       - ". $row[assureddeliverydate];
       echo "Delivery Date Time          - ". $row[deliverydatetime];
       echo "Delivery Status             - ". $row[deliverystatus];
       echo "Name Number to whom delivered   - ". $row[name_and_number_of_the_person_to_whom_del];
       echo "First Delivery attempt date     - ". $row[deliveryattemptnumber_1];
       echo "Second Delivery attempt date    - ". $row[deliveryattemptnumber_2];
       echo "Third Delivery attempt date     - ". $row[deliveryattemptnumber_3];
       echo "First delivery, fail reason     - ". $row[faileddel.attempt,reason_1];
       echo "Second delivery, fail reason    - ". $row[faileddel.attempt,reason_2];
       echo "Third delivery, fail reason     - ". $row[faileddel.attempt,reason_3];

    }
}

更新:

方法一

echo "Docket Number           - ". $row[docketno] ."</br>";

在与此相同的所有 echo 语句中使用它。

方法二

使用 HTML table标签以表格样式显示。

于 2012-04-18T05:26:54.860 回答