<?php
	//require('connect.php');
	require '../config/dbcon.php';
	if(ISSET($_POST['save'])){
		if($_FILES['file']['name']){
			$filename = explode(".", $_FILES['file']['name']);
			if($filename[1] == 'csv'){
                $handler = fopen($_FILES['file']['tmp_name'], "r");
                $sql = "DELETE FROM venkat";
                $connect->query($sql);
				while($data = fgetcsv($handler)){
					$connect->query("INSERT INTO venkat(Edit,PART_NUMBER,PART_DESCRIPTION,LIST,MOQ,LYSALES,CYSALES,TO_ORDER,STOCK,COST,RATE,OPENING,RECEIVED,PENDING,DISPATCH,AAL_PO,PY_STK,TOD_COST,GP,SEGMENT) VALUES ('".$data[0]."', '".$data[1]."', '".$data[2]."', '".$data[3]."', '".$data[4]."', '".$data[5]."', '".$data[6]."', '".$data[7]."', '".$data[8]."', '".$data[9]."', '".$data[10]."', '".$data[11]."', '".$data[12]."', '".$data[13]."', '".$data[14]."', '".$data[15]."', '".$data[16]."', '".$data[17]."', '".$data[18]."', '".$data[19]."')");
				}
				fclose($handler);
			}
		}
		header('location:index.php');
	}
?>