Hello all
I am a php new bibe, could you please help where I should a the loop at below code?
this is a PHP that delete all data from a MYSQL and then copy the table date from MS SQL(master) to mysql again. I wrote a .bat file to run this in scheldure under windows machine.
status now: the program can delete the data inside the table
it can copy data from MSSQL to MYSQL, but only one record, copy…
how to keep it loop and keep adding rows with all the data?
<?php
require_once( “config.php” );
//require_once( “__function.php” );
$conn_nmfs = odbc_connect( DB_NMFS_ODBC,
DB_NMFS_USERNAME,
DB_NMFS_PASSWORD );
$conn = new mysqli( DB_MIS_SERVER ,
DB_MIS_SERVER_USERNAME,
DB_MIS_SERVER_PASSWORD,
DB_MIS_DATABASE,
DB_MIS_SERVER_PORT );
$mysql=“DELETE FROM interface_cash_payment_chart”;
$stmt = $conn->prepare( $mysql );
$stmt->execute();
//finish delete all data in table at MYSQL
//Insert data from MS SQL to MYSQL
$str = "INSERT INTO interface_cash_payment_chart set
AREA_CODE = ?,
BLDG_CODE = ?,
LONG_DATE = ?,
DATE_YEAR = ?,
DATE_MONTH = ?,
DATE_DAY = ?,
TRX_COUNT = ?,
TRX_AMOUNT = ? ";
$stmt_in = $conn->prepare($str);
$mssql=“SELECT * FROM mis_interface_cash_payment_chart”;
$result=odbc_exec($conn_nmfs, $mssql);
$total_records = odbc_fetch_row($result);
//for($i = 0; $i < $total_records; $i++){
while($row=odbc_fetch_row($result))
{
$AREA_CODE = odbc_result($result,“AREA_CODE”);
$BLDG_CODE = odbc_result($result,“BLDG_CODE”);
$LONG_DATE = odbc_result($result,“LONG_DATE”);
$DATE_YEAR = odbc_result($result,“DATE_YEAR”);
$DATE_MONTH = odbc_result($result,“DATE_MONTH”);
$DATE_DAY = odbc_result($result,“DATE_DAY”);
$TRX_COUNT = odbc_result($result,“TRX_COUNT”);
$TRX_AMOUNT = odbc_result($result,“TRX_AMOUNT”);
$stmt_in->bind_param(“ssssssss”,
$AREA_CODE,
$BLDG_CODE,
$LONG_DATE,
$DATE_YEAR,
$DATE_MONTH,
$DATE_DAY,
$TRX_COUNT,
$TRX_AMOUNT
);
$stmt_in->execute();
}
?>