title: Retrieving data from multiple columns from two tables using join in php, as per the info provided by user
body: <p>I'm trying to create a basic shipment tracking page for my courier company. The user will provide the reference number and the query is required to pull the data in different columns from two tables. Below is the HTML code and below that is the php code. The HTML works ok but when I submit the form, the php throws a blank page. Can anyone tell me what mistake I'm doing here. Thanks in advance for the help.</p>
  
  <p>HTML Code:</p>
  
  <pre><code>&lt;form action="tracking.php" method="POST" id="insert"&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;Please enter your 9 digit Docket No:&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" size=9 name="docketno"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td colspan=2 id="sub"&gt;&lt;input type="submit"onClick="confSubmit(this.form);" name="submit" value="submit" &gt;&amp;nbsp;&amp;nbsp;&lt;input type="reset" value="Reset!"&gt;&lt;/td&gt;
  &lt;/tr&gt;&lt;/Table&gt;&lt;/form&gt;
  </code></pre>
  
  <p>PHP Code:</p>
  
  <pre><code>&lt;?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];
  
  }
  ?&gt;
  </code></pre>
  
  <p>MySql tables:</p>
  
  <pre><code>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;
  </code></pre>