Skip to content

Commit

Permalink
csv import action for student record done
Browse files Browse the repository at this point in the history
  • Loading branch information
rhalp10 committed Mar 7, 2018
1 parent 1d6de01 commit 9fcfde4
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 60 deletions.
151 changes: 110 additions & 41 deletions action/csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,84 @@

}
else{
$sql = "INSERT into user_student_detail (
student_IDNumber
,student_fName
,student_mName
,student_lName
,student_address
,student_civilStat
,student_dob
,student_gender
,student_contact
,student_admission
,student_year_grad
,student_department
)
values (
'".$getData[0]."',
'".$getData[1]."',
'".$getData[2]."',
'".$getData[3]."',
'".$getData[4]."',
'".$getData[5]."',
'".$getData[6]."',
'".$getData[7]."',
'".$getData[8]."',
'".$getData[9]."',
'".$getData[10]."',
'".$getData[11]."',
)
";
$student_IDNumber = $getData[0] ;
$student_fName = $getData[1];
$student_mName = $getData[2];
$student_lName = $getData[3];
$student_address = $getData[4];
$student_civilStat = $getData[5];
$student_dob = $getData[6];
$student_gender = $getData[7];
$student_contact = $getData[8];
$student_admission = $getData[9];
$student_year_grad = $getData[10];
$student_department = $getData[11];
$sql = mysqli_query($con,"SELECT * FROM `marital_status` WHERE marital_Name like '%$student_civilStat%'");
$mstat = mysqli_fetch_array($sql);
$student_civilStat = $mstat['ID'];

$sql = mysqli_query($con,"SELECT * FROM `cvsu_department` WHERE department_name like '%$student_department%'");
$dep = mysqli_fetch_array($sql);
$student_department = $dep['department_ID'];
if (strtoupper($student_gender) == 'MALE') {
$student_gender = "M";
}
if (strtoupper($student_gender) == 'FEMALE') {
$student_gender = "F";
}
$sql = "INSERT INTO `user_student_detail`
(
`student_ID`,
`student_userID`,
`student_img`,
`student_IDNumber`,
`student_fName`,
`student_mName`,
`student_lName`,
`student_address`,
`student_civilStat`,
`student_dob`,
`student_gender`,
`student_contact`,
`student_admission`,
`student_year_grad`,
`student_department`,
`student_status`,
`student_secretquestion`,
`student_secretanswer`)
VALUES
(
NULL,
NULL,
'temp.gif',
'".$student_IDNumber."',
'".$student_fName."',
'".$student_mName."',
'".$student_lName."',
'".$student_address."',
'".$student_civilStat."',
'".$student_dob."',
'".$student_gender."',
'".$student_contact."',
'".$student_admission."',
'".$student_year_grad."',
'".$student_department."',
'unregister',
NULL,
NULL)";
$result = mysqli_query($con, $sql);
if(!isset($result))
{
echo "<script type=\"text/javascript\">
alert(\"Invalid File:Please Upload CSV File.\");
window.location = \"index.php\"
</script>";
// echo "<script type=\"text/javascript\">
// alert(\"Invalid File:Please Upload CSV File.\");
// window.location = \"recordstudent.php\"
// </script>";
}
else {
echo "<script type=\"text/javascript\">
alert(\"CSV File has been successfully Imported.\");
window.location = \"index.php\"
</script>";
// echo "<script type=\"text/javascript\">
// alert(\"CSV File has been successfully Imported.\");
// window.location = \"recordstudent.php\"
// </script>";
}

}
Expand All @@ -70,9 +104,44 @@
fclose($file);
}
}
if(isset($_POST["Import_teacher"])){
// if(isset($_POST["Import_teacher"])){

// "INSERT INTO `user_teacher_detail`
// (`teacher_ID`,
// `teacher_userID`,
// `teacher_img`,
// `teacher_facultyID`,
// `teacher_fName`,
// `teacher_mName`,
// `teacher_lName`,
// `teacher_gender`,
// `teacher_dob`,
// `teacher_contact`,
// `teacher_address`,
// `teacher_civilStat`,
// `teacher_department`,
// `teacher_status`,
// `teacher_secretquestion`,
// `teacher_secretanswer`)
// VALUES (
// NULL,
// NULL,
// 'temp.gif',
// NULL,
// NULL,
// NULL,
// NULL,
// NULL,
// NULL,
// NULL,
// NULL,
// NULL,
// NULL,
// 'unregister',
// NULL,
// NULL);"

}
// }
if(isset($_POST["Export"])){

header('Content-Type: text/csv; charset=utf-8');
Expand Down
28 changes: 14 additions & 14 deletions csv_format.csv
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
student_IDNumber,student_fName,student_mName,student_lName,student_address,student_civilStat,student_dob,student_gender,student_contact,student_admission,student_year_grad,student_department,
3123,z,z,z,z,1,z,m,123123,6/1/2013,6/1/2013,1,
3123,z,z,z,z,1,z,m,123123,6/1/2013,6/1/2013,1,
3123,z,z,z,z,1,z,m,123123,6/1/2013,6/1/2013,1,
3123,z,z,z,z,1,z,m,123123,6/1/2013,6/1/2013,1,
3123,z,z,z,z,1,z,m,123123,6/1/2013,6/1/2013,1,
3123,z,z,z,z,1,z,m,123123,6/1/2013,6/1/2013,1,
3123,z,z,z,z,1,z,m,123123,6/1/2013,6/1/2013,1,
3123,z,z,z,z,1,z,m,123123,6/1/2013,6/1/2013,1,
3123,z,z,z,z,1,z,m,123123,6/1/2013,6/1/2013,1,
3123,z,z,z,z,1,z,m,123123,6/1/2013,6/1/2013,1,
3123,z,z,z,z,1,z,m,123123,6/1/2013,6/1/2013,1,
3123,z,z,z,z,1,z,m,123123,6/1/2013,6/1/2013,1,
3123,z,z,z,z,1,z,m,123123,6/1/2013,6/1/2013,1,
student_IDNumber,student_fName,student_mName,student_lName,student_address,student_civilStat,student_dob,student_gender,student_contact,student_admission,student_year_grad,student_department
1321,h,z,z,czxczzxc,Single,3/29/2018,Male,123123,6/1/2013,6/1/2013,Computer Science
1322,fgh,z,z,ret,Single,3/29/2018,Female,123123,6/1/2013,6/1/2013,Information Technology
1323,ty,z,z,rt,Widowed,3/29/2018,Male,123123,6/1/2013,6/1/2013,Office Administration
1324,fgh,z,z,fg,Single,3/29/2018,Male,123123,6/1/2013,6/1/2013,Office Administration
1325,gfh,z,z,asdasdasd,Married,3/29/2018,Male,123123,6/1/2013,6/1/2013,Information Technology
1326,fgh,z,z,vbc,Single,3/29/2018,Male,123123,6/1/2013,6/1/2013,Office Administration
1327,z,z,z,cxv,Single,3/29/2018,Male,123123,6/1/2013,6/1/2013,Office Administration
1328,fgh,z,z,fgh,Single,5/29/2018,Male,123123,6/1/2013,6/1/2013,Information Technology
1329,fgh,z,z,asdasdasd,Single,3/29/2018,Female,123123,6/1/2013,6/1/2013,Information Technology
1330,fgh,z,z,fgh,Single,3/29/2018,Female,123123,6/1/2013,6/1/2013,Office Administration
1331,vbnvb,z,z,zxcasd,Single,3/29/2018,Female,123123,6/1/2013,6/1/2013,Office Administration
1332,vbnvb,z,z,bvnfgh,Single,4/29/2018,Female,123123,6/1/2013,6/1/2013,Office Administration
1333,ertert,z,z,asdasdasd,Single,3/30/2018,Female,123123,6/1/2013,6/1/2013,Office Administration
9 changes: 5 additions & 4 deletions db/tracerdata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Mar 06, 2018 at 12:26 AM
-- Generation Time: Mar 07, 2018 at 05:04 PM
-- Server version: 10.1.26-MariaDB
-- PHP Version: 7.1.8

Expand Down Expand Up @@ -728,7 +728,8 @@ CREATE TABLE `user_teacher_detail` (

INSERT INTO `user_teacher_detail` (`teacher_ID`, `teacher_userID`, `teacher_img`, `teacher_facultyID`, `teacher_fName`, `teacher_mName`, `teacher_lName`, `teacher_gender`, `teacher_dob`, `teacher_contact`, `teacher_address`, `teacher_civilStat`, `teacher_department`, `teacher_status`, `teacher_secretquestion`, `teacher_secretanswer`) VALUES
(130, 8, 'temp.gif', 68, 'sarada', '', 'uchiha', 'F', '2018-01-28', '123123', '123123', 1, 2, 'register', '', ''),
(140, 17, 'temp.gif', 54, 'z', 'z', 'z', 'M', '0004-08-05', '85', 'z', 1, 1, 'register', '', '');
(140, 17, 'temp.gif', 54, 'z', 'z', 'z', 'M', '0004-08-05', '85', 'z', 1, 1, 'register', '', ''),
(141, NULL, 'temp.gif', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'unregister', NULL, NULL);

-- --------------------------------------------------------

Expand Down Expand Up @@ -1157,13 +1158,13 @@ ALTER TABLE `user_notif_type`
-- AUTO_INCREMENT for table `user_student_detail`
--
ALTER TABLE `user_student_detail`
MODIFY `student_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
MODIFY `student_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;

--
-- AUTO_INCREMENT for table `user_teacher_detail`
--
ALTER TABLE `user_teacher_detail`
MODIFY `teacher_ID` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=141;
MODIFY `teacher_ID` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=142;

--
-- AUTO_INCREMENT for table `view_counter`
Expand Down
2 changes: 1 addition & 1 deletion recordteacher.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
<div class="form-group text-center">
<input class="btn btn-success" type="submit" name="submit_recordteacher" value="Submit">

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal1">Import Excel</button>
<!-- <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal1">Import Excel</button> -->
</div>
</form>
</div>
Expand Down

0 comments on commit 9fcfde4

Please sign in to comment.