<?php
require_once 'dao/Admission.php';
if(isset($_FILES['file']))
{
	print_r($_FILES);


echo $filename=$_FILES["file"]["tmp_name"];
$ext=substr($filename,strrpos($filename,"."),(strlen($filename)-strrpos($filename,".")));

//we check,file must be have csv extention
// if($ext=="csv")
// {
  $file = fopen($filename, "r");
         while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
         {
         	
          $sn = $emapData[0];
          $student_id = $emapData[1];
          $student_name = $emapData[2];
          $guardian_phone = $emapData[3];
        $data = array("student_id"=>$student_id,"guardian_phone"=>$guardian_phone);
        print_r($data);
           $success =  $admission->update_guardian($data,$student_id);
           if ($success) {
           	echo 0;
           }else{
           	echo 1;
           }
           //break;
         }
         fclose($file);
         echo 3;
// }
// else {
//     echo "Error: Please Upload only CSV File";
// }


}

?>