-
Notifications
You must be signed in to change notification settings - Fork 0
/
insertarPlan.php
48 lines (34 loc) · 1.48 KB
/
insertarPlan.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
<?php
include 'conexion.php';
set_time_limit(300);
if(isset($_POST["Import"])){
echo $filename=$_FILES["file"]["tmp_name"];
if($_FILES["file"]["size"] > 0)
{
$file = fopen($filename, "r");
while (($emapData = fgetcsv($file, 10000, ";")) !== FALSE)
{
//It wiil insert a row to our subject table from our csv file`
$sql = "INSERT into plandeestudio (`ano`, `periodo`, `nombreSede`, `planDeEstudio`,escuela, `codJornada`, `nivel`, `seccion`, `codAsignatura`, `nombreAsignatura`, `rutDocente`, `Instructor`)
values('$emapData[0]','$emapData[1]','$emapData[2]','$emapData[3]','$emapData[4]','$emapData[5]','$emapData[6]','$emapData[7]','$emapData[8]','$emapData[9]','$emapData[10]','$emapData[11]')";
//we are using mysql_query function. it returns a resource on true else False on error
$result = mysqli_query( $con, $sql );
if(! $result )
{
echo "<script type=\"text/javascript\">
alert(\"Invalid File:Please Upload CSV File.\");
window.location = \"IngresoPlanDeEstudio.php\"
</script>";
}
}
fclose($file);
//throws a message if data successfully imported to mysql database from excel file
echo "<script type=\"text/javascript\">
alert(\"CSV File has been successfully Imported.\");
window.location = \"IngresoPlanDeEstudio.php\"
</script>";
//close of connection
mysqli_close($con);
}
}
?>