<?php
session_start();

// ----------------from db ---f------------------
$servername = 'localhost';
$username = 'coolmans_db';
$password = 'e1E]0Mfua.0T4LL';
$port = 10060;
$dbname = 'coolmans_pt2';
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); 
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// ----------------to db ---------------------
$servername1 = 'localhost';
$username1 = 'coolmans_npeidcs';
$password1 = 'e1E]0Mfua.0T4LL';
$port = 10060;
$dbname1 = 'coolmans_npeidcs';  
$conn1 = new PDO("mysql:host=$servername1;dbname=$dbname1", $username1, $password1); 
$conn1->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// ===========================
    $sql = "Select * from s_salma  limit 10";
    foreach ($conn->query($sql) as $row) {
        
        //$sql_2 = "select * from s_salma where REF_NO = '" . $row["REF_NO"] . "'";
        //$result_2 = $conn1->query($sql_2);
        //if (!$row_2 = $result_2->fetch()) {
        
       
            
            
              $sql_l = "Insert into s_salma  (REF_NO,TRN_TYPE,SDATE,C_CODE,CUS_NAME,C_ADD1,TYPE,SAL_EX,DISCOU,AMOUNT,GST,GRAND_TOT,DUMMY_VAL,DIS,DIS1,DIS2,DIS_RUP,CASH,TOTPAY,ORD_NO,ORD_DA,SETTLED,TOTPAY1,DES_CAT,DEPARTMENT,REMARK,CANCELL,BTT,VAT,VAT_VAL,Brand,DEV,Account,Accname,Costcenter,RET_AMO,cre_pe,Comm,red,deli_date,seri_no,points,LOCK1,deliin,SVAT,req_date,tmp_no,vat_no,s_vat_no,veheno,driver,loaddate,pirnt_serial,userid,del_cus,dele_no,nonrtn,company,use_name,vatrate,del_cusname,remain_date,vehino,flg_caj,invtype,SAL_EX1) values
             ('".$row['REF_NO']."','".$row['TRN_TYPE']."','".$row['SDATE']."','".$row['C_CODE']."','".$row['CUS_NAME']."','".$row['C_ADD1']."','".$row['TYPE']."','".$row['SAL_EX']."','".$row['DISCOU']."','".$row['AMOUNT']."','".$row['GST']."','".$row['GRAND_TOT']."','".$row['DUMMY_VAL']."','".$row['DIS']."','".$row['DIS1']."','".$row['DIS2']."','".$row['DIS_RUP']."','".$row['CASH']."','".$row['TOTPAY']."','".$row['ORD_NO']."','".$row['ORD_DA']."','".$row['SETTLED']."','".$row['TOTPAY1']."','".$row['DES_CAT']."','".$row['DEPARTMENT']."','".$row['REMARK']."','".$row['CANCELL']."','".$row['BTT']."','".$row['VAT']."','".$row['VAT_VAL']."','".$row['Brand']."','".$row['DEV']."','".$row['Account']."','".$row['Accname']."','".$row['Costcenter']."','".$row['RET_AMO']."','".$row['cre_pe']."','".$row['Comm']."','".$row['red']."','".$row['deli_date']."','".$row['seri_no']."','".$row['points']."','".$row['LOCK1']."','".$row['deliin']."','".$row['SVAT']."','".$row['req_date']."','".$row['tmp_no']."','".$row['vat_no']."','".$row['s_vat_no']."','".$row['veheno']."','".$row['driver']."','".$row['loaddate']."','".$row['pirnt_serial']."','".$row['userid']."','".$row['del_cus']."','".$row['dele_no']."','".$row['nonrtn']."','".$row['company']."','".$row['use_name']."','".$row['vatrate']."','".$row['del_cusname']."','".$row['remain_date']."','".$row['vehino']."','".$row['flg_caj']."','".$row['invtype']."','".$row['SAL_EX1']."')";
            $result_1 = $conn1->query($sql_l);
            
             
        
        //}
    }
    
    echo 'Done';
  

?>