-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.php
More file actions
173 lines (150 loc) · 5.26 KB
/
Copy pathsample.php
File metadata and controls
173 lines (150 loc) · 5.26 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
$conn = new mysqli('localhost', 'root', '', 'mace')
or die ('Cannot connect to db');
$del= mysqli_query($conn, "DELETE FROM student where Course='Course' AND Branch='Branch'");
$de2= mysqli_query($conn, "DELETE FROM student where Course=' ' AND Branch=' '");
$insertroom=mysqli_query($conn,"INSERT INTO finalroom (No, room_name, capacity, status,occupy) SELECT No, room_name, capacity, status, occupy FROM `room21` ");
$query = mysqli_query($conn,"SELECT room_name,capacity,status FROM finalroom");
while($row= mysqli_fetch_array($query))
{
$insp [] = $row['room_name'];
}
foreach ($insp as $inspe)
{
$select1=mysqli_query($conn,"SELECT capacity,status FROM finalroom where room_name='$inspe' ");
$row = mysqli_fetch_assoc($select1);
$se=$row['capacity'];
$stat=$row['status'];
if($stat==2){
$se1=$se/2;
}
else {
$se1=$se;
}
$updatefinal=mysqli_query($conn,"UPDATE finalroom SET Current='$se1' WHERE room_name='$inspe'");
}
$query1 = mysqli_query($conn,"SELECT * FROM course");
unset($inspec);
while($row= mysqli_fetch_array($query1))
{
$inspec [] = $row['No'];
}
$quer = mysqli_query($conn,"SELECT room_name,capacity,status FROM finalroom");
unset($inspq);
while($row= mysqli_fetch_array($quer))
{
$inspq [] = $row['room_name'];
}
foreach ($inspec as $inspe1)
{
$selectc1=mysqli_query($conn,"SELECT * FROM course where No='$inspe1' ");
$row = mysqli_fetch_assoc($selectc1);
$cour=$row['Course'];
$branch=$row['Branch'];
$tot=$row['total'];
if($tot<=0)
{
break;
}
foreach ($inspq as $select)
{
$selectc1=mysqli_query($conn,"SELECT * FROM course where No='$inspe1' ");
$row = mysqli_fetch_assoc($selectc1);
$cour=$row['Course'];
$branch=$row['Branch'];
$tot=$row['total'];
if($tot<=0)
{
break;
}
if($tot<=$se1)
{
$totupdater=mysqli_query($conn,"UPDATE finalroom SET Current='$tot' WHERE room_name='$select'");
}
$select1=mysqli_query($conn,"SELECT * FROM finalroom where room_name='$select' ");
$row = mysqli_fetch_assoc($select1);
$se=$row['capacity'];
$stat=$row['status'];
$ce=$row['Current'];
$de=$row['Current'];
$quy12= mysqli_query($conn,"SELECT * FROM roomcourse WHERE room_name='$select'");
$row13 = mysqli_fetch_assoc($quy12);
$g1=$row13['Course'];
$g2=$row13['Branch'];
$g3=$row13['room_name'];
$g4=$row13['total'];
$afe=(mysqli_query($conn,"SELECT * from course where Course!='$g1'"));
$s= mysqli_affected_rows($conn);
if($s>0)
{
$selectc2=mysqli_query($conn,"SELECT * FROM course where No='$inspe1' ");
$row = mysqli_fetch_assoc($selectc2);
$cour=$row['Course'];
$branch=$row['Branch'];
$tot=$row['total'];
$qur= mysqli_query($conn,"INSERT INTO roomcourse (Course,Branch,room_name) VALUES ('$cour','$branch','$select')");
$roomupdater= mysqli_query($conn,"UPDATE roomcourse SET total='$ce' WHERE room_name='$select' AND Course='$cour' AND Branch='$branch'");
$re=$ce;
$le=$se-$ce;
$le=abs($le);
$pe=$le;
if($le>=$se1)
{
$pe=$se1;
}
if($totl<=$pe)
{
$pe=$totl;
}
$totalupdater=mysqli_query($conn,"UPDATE finalroom SET Current='$pe' WHERE room_name='$select'");
$totaupdater=mysqli_query($conn,"UPDATE finalroom SET capacity='$le' WHERE room_name='$select'");
$totl=$tot-$re;
$totl=abs($totl);
$courseupdater= mysqli_query($conn,"UPDATE course SET total='$totl' WHERE Course='$cour' AND Branch='$branch'");
if($pe<=0)
{
$del= mysqli_query($conn,"DELETE FROM finalroom WHERE room_name='$select'");
$quer = mysqli_query($conn,"SELECT room_name,capacity,status FROM finalroom");
unset($inspq);
while($row= mysqli_fetch_array($quer))
{
$inspq [] = $row['room_name'];
}
}
echo $inspe1;
}
else {
break;
}
}
}
$querZ = mysqli_query($conn,"SELECT * FROM roomcourse");
unset ($insw);
$lastup1= mysqli_query($conn,"UPDATE student SET Room='aa'");
while($row= mysqli_fetch_array($querZ))
{
$insw [] = $row['No'];
}
foreach ($insw as $new)
{
$selectb1=mysqli_query($conn,"SELECT * FROM roomcourse where No='$new'");
$row = mysqli_fetch_assoc($selectb1);
$ab=$row['Course'];
$ac=$row['Branch'];
$ad=$row['room_name'];
$ae=$row['total'];
$lastup= mysqli_query($conn,"UPDATE student SET Room='$ad' WHERE Course='$ab' AND Branch='$ac' AND Room='aa' LIMIT $ae");
}
$querZy = mysqli_query($conn,"SELECT * FROM room21");
unset($insl);
while($row= mysqli_fetch_array($querZy))
{
$insl [] = $row['room_name'];
}
foreach ($insl as $res)
{
$rs=$res;
$ins1234=mysqli_query($conn,"INSERT INTO $res (Reg_no,Course) SELECT Register,Course FROM student WHERE Room='$rs'");
echo $res;
}
?>