forked from leemacat2/FinalMadApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddVolunteer.php
70 lines (66 loc) · 2.32 KB
/
AddVolunteer.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
<?php
echo "<html><body>";
$flag=0;
$name=$_COOKIE['uname'];
//$name="anupama chingacham";
$con=mysql_connect("localhost", "root") or die("Could not connect to database. Please check your internet connection");
$db = mysql_select_db("madapp",$con);
$r=0;
$query=mysql_query("select credit from user where name='$name';");
$r=mysql_fetch_row($query);
echo " You have $r[0] credits <br><br>";
$r1=mysql_query("select id from user where name='$name';");
$id=mysql_fetch_row($r1);
echo "<table><tr><b><td>STATUS</td><td><pre> </pre></td><td>DATE</td><td><pre> </pre></td><td>REMARKS</td></b></tr>";
//absent without substitute
$rm1=mysql_query("select class_id from userclass where user_id='$id[0]' and status='absent';");
if(!(is_null($rm1)))
{
while($subs=mysql_fetch_row($rm1))
{
$r2=mysql_query("select class_on from class where id='$subs[0]' ORDER BY class_on;");
while($r3=mysql_fetch_row($r2))
{
echo "<tr><td>Absent without substitute</td><td></td><td>$r3[0]</td><td></td><td>Lost 2 credits</td></tr>";
}
$flag++;
}
}
//absent with substitute
$rm2=mysql_query("select class_id from userclass where user_id='$id[0]' and status='attended' and substitute_id!=0;");
if(!(is_null($rm2)))
{
while($subs=mysql_fetch_row($rm2))
{
$r2=mysql_query("select class_on from class where id='$subs[0]' ORDER BY class_on;");
while($r3=mysql_fetch_row($r2))
{
echo "<tr><td>Absent with substitute</td><td></td><td>$r3[0]</td><td></td><td>Lost 1 credit</td></tr>";
}
$flag++;
}
}
//substituted
$rm3=mysql_query("select class_id from userclass where substitute_id='$id[0]' and status='attended';");
if(!(is_null($rm3)))
{
while($subs=mysql_fetch_row($rm3))
{
$res=mysql_query("SELECT batch_id FROM userbatch WHERE user_id =1662");$res1=mysql_fetch_row($res);
$r2=mysql_query("select class_on, batch_id from class where id='$subs[0]' ORDER BY class_on;");
while($r3=mysql_fetch_row($r2))
{
//for own class
if($r3[1]==$res1[0])
echo "<tr><td>Substituted for own class</td><td></td><td>$r3[0]</td><td></td><td>Gained 1 credit</td></tr>";
//for other class
if($r3[1]!=$res1[0])
echo "<tr><td>Substituted</td><td></td><td>$r3[0]</td><td></td><td>Gained 0.5 credit</td></tr>";
}
$flag++;
}
}
if($flag==0)
echo "You have neither substituted nor been absent.";
echo "</table></body></html>";
?>