-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove.php
134 lines (130 loc) · 2.56 KB
/
remove.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
ob_start();
session_start();
include('connect.php');
if(!isset($_SESSION['userid']))
header('location:message.php');
if(isset($_POST['showbran']))
{
$c=$_POST['course'];
$type=$_POST['type'];
$q="select branch from course where name ='$c' and type='$type'";
$r=mysqli_query($con,$q);
if($r)
{
while($row=mysqli_fetch_array($r))
{
echo $row[0];
}
}
}
if(isset($_POST['rembran']))
{
$b=$_POST['rembran'];
$c=$_POST['cour'];
$type=$_POST['type'];
$branch='';
$prefix='';
$q="select branch,branch_pre from course where name ='$c' and type='$type'";
$r=mysqli_query($con,$q);
if($r)
{
while($row=mysqli_fetch_array($r))
{
$branch=$row[0];
$prefix=$row[1];
}
}
$branch=explode(',',$branch);
$prefix=explode(',',$prefix);
if(count($branch)==1){
$new_b='';
$new_p='';
}
else{
for($i=0;$i<count($branch);$i++){
if($branch[$i]===$b){
unset($branch[$i]);
break;
}
}
unset($prefix[$i]);
$branch=array_values($branch);
$prefix=array_values($prefix);
$new_b=implode(',',$branch);
$new_p=implode(',',$prefix);
}
$q="update course set branch='$new_b',branch_pre='$new_p' where name ='$c' and type='$type'";
$r=mysqli_query($con,$q);
if($r)
echo 'Branch Removed Successfully!';
else
echo 'Some Error Encountered. Please try again!';
}
else if(isset($_POST['showcour']))
{
$type=$_POST['type'];
$q="select name from course where type='$type' order by name";
$r=mysqli_query($con,$q);
if($r)
{
while($row=mysqli_fetch_array($r))
{
echo '<option>'.$row[0].'</option>';
}
}
}
else if(isset($_POST['showpre'])){
$type=$_POST['type'];
$course=$_POST['course'];
$q="select cour_pre from course where name='$course' and type='$type'";
$r=mysqli_query($con,$q);
if($r){
while($row=mysqli_fetch_array($r)){
echo $row[0];
}
}
}
else if(isset($_POST['remcour']))
{
$c=$_POST['remcour'];
$type=$_POST['type'];
$q="delete from course where name='$c' and type='$type'";
$r=mysqli_query($con,$q);
if($r)
echo 'Course Removed Successfully!';
}
else if(isset($_GET['showexte']))
{
$q="select name from extension";
$r=mysqli_query($con,$q);
if($r)
{
while($row=mysqli_fetch_array($r))
{
echo"<option>".$row[0]."</option>";
}
}
}
else if(isset($_GET['exte']))
{
$e=$_GET['exte'];
$q="delete from extension where name='$e'";
$r=mysqli_query($con,$q);
}
else if(isset($_GET['listexte']))
{
$q="select name from extension";
echo '<h3>List of Extension Centers</h3><hr style="">';
$r=mysqli_query($con,$q);
if($r)
{
echo '<ul>';
while($row=mysqli_fetch_array($r))
{
echo"<li>".$row[0]."</li>";
}
echo '</ul>';
}
}
?>