<?session_start();
include("opendb.php");
//print sizeof($a);

if(isset($_POST['upd']))
{
    $ff=$_REQUEST['ff'];
  if($ff !="none")
  {
      
   $imagename=$_FILES['ff']['name'];
       $filepath= "";
       $tmp = $_FILES['ff']['tmp_name'];
       move_uploaded_file($tmp, $filepath . $imagename) or die(' err:could not copy file');
  
  
  
 }
//$fp=fopen("./txtfiles/$ff_name","r") or die("Cant open file");
$fp=fopen($filepath.$imagename,"r") or die("Cant open file");
$i=1;
include("opendb.php");

mysqli_query($db,"delete from exciseopening_kerala")or die('Err:'.mysqli_error($db));
print $m=("delete from exciseopening_kerala")or die('Err:'.mysqli_error($db));

$i=1;
while(!feof($fp))
{
 $line=fgets($fp,1024);
 $spline=explode("\t",$line);
if(strlen($spline[0])>0)
{
//$sql="insert into spareopstock values('".addslashes(trim($spline[0]))."','".addslashes(trim($spline[1]))."','".addslashes(trim($spline[2])."','".$brcode."','".$spline[3]."')";
 
$qty = trim($spline[3]);
 $qty = str_replace(',', '', $qty);

 $mrp = trim($spline[4]);
 $mrp = str_replace(',', '', $mrp);
 $ndp = trim($spline[5]);
 $ndp = str_replace(',', '', $ndp);
 $moving = trim($spline[6]);
 $moving = str_replace(',', '', $moving);
 $price = trim($spline[8]);
 $price = str_replace(',', '', $price);
 
 
 
 

print $sql="insert into exciseopening_kerala  values('".addslashes(trim($spline[0]))."','".addslashes(trim($spline[1]))."','".addslashes(trim($spline[2]))."',$qty,$mrp,$ndp,$moving,'".$spline[7]."',$price)";

print $i++.". ".$sql."<br>";
mysqli_query($db,$sql) or die('Insert Err:'.mysqli_error($db));
}
}
print "<script> alert('Done');</script>";
}

?>

<link rel="stylesheet" href="style.css" type="text/css" />
<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
//etr{background-color:c1d799}
.mnu{margin-left:5}
</style>
<center>
<br><br><br><br><br><br>
Itemcode -  Item Name - Location-(Bcranch)-Qty<br>
<form action='<?print $PHP_SELF?>' method='post' ENCTYPE="multipart/form-data">
<table border=0 width=60% cellspacing=1 cellpadding=1 bgcolor='darkbrown'>
<tr><td align=center bgcolor=white>
<table >
<th colspan=2 bgColor=c1d799>Upload excise Opening Stock
<tr><td>File </td><td><input type=file name='ff'></td></tr>
<tr bgColor='lightsteelblue'><td align=center colspan=2 ><input type=submit value='Upload' name='upd'></td></tr>
</table>
</td></tr>
</table>
</form>
