my first function is fetching account numbers from a table (database 1 )and i need to put it on an array
the second functions is a long waybill script that will fetch waybill info form (database2)
how do i use php to process the result retrieved from this two functions
I need to create a function to select only waybiils where timestamp is null and then add the new outsnading info to a new table
please kindlt help me with that
here is what i have now
<?php
//This is a controller file. It will include a template file and also a class
require_once ('paths.php');
function fetchAccount()
{
require(CONNECTIONS.'conn.php');
$sql = "SELECT * FROM Internal_Docs_accounts";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
$lines[] = $rows;
}
return $lines;
}
function fetchWaybillScript(){
require(CONNECTIONS.'connection.php');
$sql = "SELECT * FROM (
SELECT
Customer_Information.Branch AS Branch,
Waybill_Information.Waybill_Date AS Waybill_Date,
Rate_Information.WaybillNUmber AS WaybillNumber,
Waybill_Information.Customer_Reference AS Customer_Reference,
Waybill_Information.To_Ops_Branch AS To_Ops_Branch,
DeliverySheet_Information.Route AS Route,
Rate_Information.Account_Number AS Account_Number,
Customer_Information.Customer_Name AS Customer_Name,
Waybill_Information.Service_Type AS Service_Type,
Waybill_Information.Scan_Back_Reason_Code AS Scan_Back_Reason_Code,
POD_Information.POD_Date AS POD_Date
FROM
Rate_Information
INNER JOIN Waybill_Information ON
Waybill_Information.WaybillNumber = Rate_Information.WaybillNumber AND
YEAR(Waybill_Information.Waybill_Date) = YEAR(CURDATE()) AND
MONTH(Waybill_Information.Waybill_Date) >= (MONTH(CURDATE()) - 1)
INNER JOIN Customer_Information ON
Rate_Information.Account_Number = Customer_Information.Account_Number
LEFT JOIN POD_Information ON
POD_Information.WaybillNumber = Rate_Information.WaybillNumber
LEFT JOIN Delivery_Waybills ON
Delivery_Waybills.WaybillNumber = Waybill_Information.WaybillNumber
LEFT JOIN DeliverySheet_Information ON
DeliverySheet_Information.Delivery_Number = Delivery_Waybills.Delivery_Number AND
Delivery_Waybills.WaybillNumber IS NOT NULL) AS Data LIMIT 5";
$result=mysql_query($sql);
/*while($row=mysql_fetch_array($result)){
$lines2[] = $rows;
}
return $lines2;*/
}
function insertWaybillScript($waybill){
//need to check if waybill is fetched sucessfully before i can add to anew table and if it exist i the acc list how do i do that please help me out
/*if ($waybill == null) {
$sql = "INSERT INTO Internal_Docs_waybills_outsanding
(Branch, WaybillDate, WaybillNumber, Customer_Reference, To_Ops_Branch, Route, Account_Number, Customer_Name, Service_Type, Scan_Back_Reason_Code, POD_Date, Date_Invoice_Returned) VALUES (
'".$data[1]."', '".$data[2]."', '".$data[3]."', '".$data[4]."', '".$data[5]."', '".$data[6]."', '".$data[7]."', '".$data[8]."', '".$data[9]."', ' '".$data[10]."'', '".$data[11]."', '".$data[12]."')";
//PLEASE DO INSERT TO WAYBILL TABLE
}
}*/
while($row=mysql_fetch_array($result)){
$branch = $row['Branch'];
$waybilldate = $row['Waybill_Date'];
$waybillnumber = $row['WaybillNumber']
$cus_ref= $row['Customer_Reference'];
$to_ops_branch= $row['To_Ops_Branch'];
$route= $row['Route'];
//$email= $row['EMAIL'];
$acc_num= $row['Account_Number'];
$cus_name= $row['Customer_Name'];
$service_type= $row['Service_Type'];
$scan_back_reason_code= $row['Scan_Back_Reason_Code'];
$pod_date = $row['POD_Date'];
$date_in_rec = $row['Date_Invoice_Received'];
if ($branch == null) {
$sql = "INSERT IGNORE INTO Internal_Docs_waybills_outsanding
(Branch, WaybillDate, WaybillNumber, Customer_Reference, To_Ops_Branch, Route, Account_Number, Customer_Name, Service_Type, Scan_Back_Reason_Code, POD_Date, Date_Invoice_Returned) VALUES (
'".$branch."', '".$waybilldate."', '".$waybillnumber."', '".$cus_ref."', '".$to_ops_branch."', '".$route."', '".$acc_num."', '".$cus_name."', '".$service_type."', ' '".$scan_back_reason_code."'', '".$pod_date."', '".$data[12]."')";
$result=mysql_query($sql);
//PLEASE DO INSERT TO WAYBILL TABLE
}
}
}
?>