<?php
// Connect to the MySQL database
include 'Dbconnect.php';
// Connect to the Microsoft Access database
//$access_conn = odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq={D:/IYARIN.accdb}", "", "");
$mdbFilename="D:/IYARIN.accdb";
$access_conn = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$mdbFilename", "", "");
// Check the Microsoft Access connection
if (!$access_conn) {
die("Access connection failed: " . odbc_errormsg());
}
// Prepare and execute the SQL query
$sql = "SELECT * FROM Sale_tbl
WHERE Sale_tbl.T_date='2023-02-07'";
$result = mysqli_query($mysql_conn, $sql);
// Loop through the data and insert each record into the Microsoft Access database
while ($row = mysqli_fetch_assoc($result)) {
// Access the columns using the field names
$column1 = $row["T_date"];
$column2 = $row["CustID"];
$column3 = $row["Custname"];
// Prepare and execute the insert query
$insert_sql = "INSERT INTO Sale_tbl (SendDTE, CustID, ShopName) VALUES ('$column1', '$column2', '$column3')";
$insert_result = odbc_exec($access_conn, $insert_sql);
// Check the result of the insert query
if (!$insert_result) {
die("Insert query failed: " . odbc_errormsg());
}
}
// Free the result and close the connections
mysqli_free_result($result);
mysqli_close($mysql_conn);
odbc_close($access_conn);