Greeting ,
I am using an ODBC connection with qucikbooks. Using PHP i can show quickbooks data on my website. Now I would like to save that data in my local MYSQL. So I create an table and some fields.
//this line gets data from quickbooks connection
$query = odbc_exec($conn, "SELECT GivenName FROM Customers");
//fetch data in an array
while($row = odbc_fetch_array($query)){
//Go through the array and save the data into MYSQL.
foreach ($row as $key => $value) {
echo $value . "<br>";
//Insert data into mySQL.
$sql = "INSERT INTO Customers (GivenName) VALUES ('$value') ";
if (mysqli_query($mysqlconn, $sql)) {
echo "New record created successfully";
}
}
}
The foreach loop above dont work.
My question is how I can use foreach loop to get get the data from an array, and insert it into mysql table; and also dont insert any empty field.
Many Thanks