Hi All
I am selecting information from a one database and adding it to the other database but my insert function does not work , im testing with only one function one if i am retrieving many information/records how do i add them into the new table lets say i got like five rows in my first resource and i want to add all those row to the new tbale
It always add the first record on the list , How can i add all of them pls help
<?php
require_once ('paths.php');
require (CONNECTIONS.'conn.php');
require (CONNECTIONS.'connection.php');
$i=0;
$resource1 = "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)
AS Data LIMIT 20";
$result1=mysql_query($resource1);
$keys=array_keys(mysql_fetch_array($result1));
while ($rows = mysql_fetch_array($result1)) {
$branch = $rows['Branch'];
$waybilldate = $rows['Waybill_Date'];
$waybillnumber = $rows['WaybillNumber'];
$cus_ref= $rows['Customer_Reference'];
$to_ops_branch= $rows['To_Ops_Branch'];
$route= $rows['Route'];
$acc_num= $rows['Account_Number'];
$cus_name= $rows['Customer_Name'];
$service_type= $rows['Service_Type'];
$scan_back_reason_code= $rows['Scan_Back_Reason_Code'];
$pod_date = $rows['POD_Date'];
foreach ($keys as $speckey) {
$got[$i][$speckey]=$rows[$speckey];
}
$i++;
}
return $got;
require (CONNECTIONS.'db_conn.php');
$resource2 = "INSERT IGNORE INTO Internal_Docs_waybills_outstanding
(Branch, Waybill_Date, WaybillNumber, Customer_Reference, To_Ops_Branch, Route, Account_Number, Customer_Name, Service_Type, Scan_Back_Reason_Code, POD_Date, Date_Invoice_Received) VALUES (
'".$branch."', '".$waybilldate."', '".$waybillnumber."', '".$cus_ref."', '".$to_ops_branch."', '".$route."', '".$acc_num."', '".$cus_name."', '".$service_type."', '".$scan_back_reason_code."', '".$pod_date."', NOW())";
$result2=mysql_query($resource2) or die("Cannot insert into Internal Docs waybills outstanding");
?>
I have printed out my result it shows perfectly but my issue is adding to a new table , How do i insert multiple records at onces