<?php

	//$link=mysqli_connect("localhost","legendco_examuser","lc***2000###","legendco_exam");
	include "config.php";
	include "xlsx.php";
    //$xlfilename=$_FILES['excel']['name'];
    
   
    //echo $xlfilename;

if($link){
		
		mysqli_query($link,"TRUNCATE TABLE sms_xl");  //delete all data from table
		
		$excel=SimpleXLSX::parse($_FILES['excel']['tmp_name']);
		//echo "<br><br><br><br>";
		echo "<pre>";	
				$excel->dimension(2);
		$excel->sheetNames();
        $sheet=0;
		$rowcol=$excel->dimension($sheet);
        		 $c=0;
        if($rowcol[0]!=1 &&$rowcol[1]!=1){
		foreach ($excel->rows($sheet) as $key => $row) {
			 $c++;
			//print_r($row);
			$q="";
			foreach ($row as $key => $cell) {
				$q.="'".$cell. "',";
				}
			if ($c>1){
			$date_today=date("Y-m-d");
          $query = "insert into sms_xl (mobile_number,txt_sms) values (".rtrim($q,",").")";
			$result=mysqli_query($link,$query);
			//echo $query;
					}
		}
		if($result){
		$tot=($c++)-1;
        echo $tot;
        }
        else{
            echo 0;
        }
        
        
		}
		
		
		
}



?>