-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourse_allocation_excel.php
84 lines (68 loc) · 1.79 KB
/
course_allocation_excel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
session_start();
include("connection.php");
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
if (isset($_POST['course_allocation_excel_data']))
{
$filename = $_FILES['import_file']['name'];
$file_ext= pathinfo($filename, PATHINFO_EXTENSION);
$allowed_ext =[ 'xls', 'csv', 'xlsx'];
if(in_array($file_ext, $allowed_ext))
{
$inputFileNamePath = $_FILES['import_file']['tmp_name'];
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileNamePath);
$data = $spreadsheet->getActiveSheet()->toArray();
$count='0';
foreach($data as $row)
{
// if($count> 0)
// {
// $faculty_email = $row[1] . "<br>";
// // gettype($faculty_email) . "<br>";
// // $new[] = array_push($faculty_email);
// echo $faculty_email = implode('<br>',array_unique(explode('<br>', $faculty_email)));
// }
if($count> 0)
{
$course_id= $row[0] ;
$batch = $row[2] ;
$branch= $row[3] ;
$faculty_id=$row[4] ;
$semester =$row[6] ;
// $division =$row[5];
// $batch = $row[6];
$studentQuery ="INSERT INTO course_allocation( course_id, batch,branch, faculty_id, semester)
VALUES ( '$course_id','$batch' ,'$branch' ,'$faculty_id' ,'$semester' )";
$result =mysqli_query(createConn(),$studentQuery);
$msg =true;
}
else
{
$count='1';
}
}
if(isset($msg))
{
$_SESSION['message']="Successfully Imported ";
header('Location: course_allocation.php');
exit(0);
}
else
{
$_SESSION['message']="NOT Imported ";
header('Location: course_allocation.php');
exit(0);
}
}
else
{
$_SESSION['message']="Invalid File";
header('Location: course_allocation.php');
exit(0);
}
}else{
echo "not sellll";
}
?>