Hello am trying to update rows in my savings table but getting values from an excel file using a primary key as account_id which both the file and the table.My code does not execute like expected
if(isset($_POST['import'])){
$filename = explode(".", $_FILES["file"]["name"]);
if ($filename[1]=="csv") {
$file = $_FILES['file']['tmp_name'];
$openFile = fopen($file,'r');
while ($dataFile = fgetcsv($openFile,3000,",")) {
$acc = $dataFile[0];
$amount_deposited = $dataFile[2];
$recovered_amount = $dataFile[3];
/*update balances */
$insert = "UPDATE savings SET balance = balance+'$amount_deposited' WHERE account_id ='$acc'";
$run_insert = mysql_query($insert);
$insert = "INSERT INTO transactions values('','$acc','Saving','$recovered_amount','',now(),'')";
$run_insert = mysql_query($insert);
}
echo "<div id='alert'>Successfully ADDED</div>";
} else {
echo "You must choose a CSV file to import";
}
}