-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddcourse.php
51 lines (44 loc) · 1.3 KB
/
addcourse.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
<?php
if(isset($_POST) and $_POST['submitForm'] == "Add" ){
$instructor = "test instructor";
$course = $_POST['course_num'];
$timing = $_POST['timing'];
$days = $_POST['days'];
$n = count($days);
echo $course . "on ". $timing. " days ";
for($i=0; $i < $n; $i++){
echo $days[$i]. " " ;
}
$con = new MongoClient();
// echo "Connection to database successfully";
if($con){
// Select Database
$db = $con->acadSchedular;
$student = [];
// Select Collection
$collection = $db->courses;
$insert = array("instructor_name" => $instructor, "course_name" => $course, "timing" => $timing, "days" => $days, " students" => $student);
$collection ->insert($insert);
echo "course created";
$collection = $db->schedule;
echo "schedule of instructor is updating";
for($i=0 ; $i < count($days); $i++)
{
// echo $a['days'][$i];
$collection->update(array("name"=>$instructor), array('$push' => array($days[$i] => array($timing, $course))));
//print_r($d);
}
// print_r($a);
echo " schedule of instructor has updated ";
/*$qry = array("user" => $usr_email,"password" => md5($usr_password));
$result = $people->findOne($qry);
if($result){
$success = "You are successully loggedIn";
// Rest of code up to you....
}*/
} else {
echo "error";
die("Mongo DB not installed");
}
}
?>