/www/mod.php
https://bitbucket.org/thomascherian91/online-hostel-manager · PHP · 111 lines · 94 code · 14 blank · 3 comment · 5 complexity · 94781604c7a82a8d52c4219d32695dd5 MD5 · raw file
- // mess_cut
- <?php
- $time=date("H:i");
- if($time>$t)
- {
- header('Location: /timeout.php');
- }
- ?>
- //mess_req_day
- <?php
- $q1=mysql_query("select count(uid) from students") or die(mysql_error());
- $q2=mysql_query("select count(id) from guest") or die(mysql_error());
- $q3=mysql_query("select count(id) from staff") or die(mysql_error());
- $r1=mysql_fetch_array($q1) or die(mysql_error());
- $r2=mysql_fetch_array($q2) or die(mysql_error());
- $r3=mysql_fetch_array($q3) or die(mysql_error());
- $c1=$r1['count'];
- $c2=$r2['count'];
- $c3=$r3['count'];
- $strength=($c1+$c2+$c3)*$mess_days;
- $tot_no=$c1+$c2+$c3;
- $q1v=mysql_query("select count(uid) from students where veg_non='YES'") or die(mysql_error());
- $q2v=mysql_query("select count(id) from guest where veg_non='YES'") or die(mysql_error());
- $q3v=mysql_query("select count(id) from staff where veg_non='YES'") or die(mysql_error());
- $r1v=mysql_fetch_array($q1v) or die(mysql_error());
- $r2v=mysql_fetch_array($q2v) or die(mysql_error());
- $r3v=mysql_fetch_array($q3v) or die(mysql_error());
- $c1v=$r1v['count'];
- $c2v=$r2v['count'];
- $c3v=$r3v['count'];
- $tot_veg=$c1v+$c2v+$c3v;
- $q1n=mysql_query("select count(uid) from students where veg_non='NO'") or die(mysql_error());
- $q2n=mysql_query("select count(id) from guest where veg_non='NO'") or die(mysql_error());
- $q3n=mysql_query("select count(id) from staff where veg_non='NO'") or die(mysql_error());
- $r1n=mysql_fetch_array($q1n) or die(mysql_error());
- $r2n=mysql_fetch_array($q2n) or die(mysql_error());
- $r3n=mysql_fetch_array($q3n) or die(mysql_error());
- $c1n=$r1n['count'];
- $c2n=$r2n['count'];
- $c3n=$r3n['count'];
- $tot_non=$c1n+$c2n+$c3n;
- $cut_veg=0;
- $cut_non=0;
- $date=date('Y-m-d');
- $result=mysql_query("select * from student where veg_non='YES'") or die(mysql_error());
- while($row=mysql_fetch_array($result))
- {
- $id=$row['uid'];
- $result1=mysql_query("select * from mess_cut where id='$id'") or die(mysql_error());
- while($row1=mysql_fetch_array($result1))
- {
- if(($date>=$row1['ffrom'])&&($date<=$row1['tto']))
- {
- $cut_veg++;
- break;
- }
- }
- }
- $result1=mysql_query("select * from student where veg_non='NO'") or die(mysql_error());
- while($row1=mysql_fetch_array($result1))
- {
- $id=$row1['uid'];
- $result2=mysql_query("select * from calc_veg where id='$id'") or die(mysql_error());
- while($row2=mysql_fetch_array($result2))
- {
- if(($date>=$row2['ffrom'])&&($date<=$row2['tto']))
- {
- $cut_veg--;
- break;
- }
- }
- $result3=mysql_query("select * from mess_cut where id='$id'") or die(mysql_error());
- while($row3=mysql_fetch_array($result3))
- {
- if(($date>=$row3['ffrom'])&&($date<=$row3['tto']))
- {
- $cut_non++;
- break;
- }
- }
- }
- $req_veg=$tot_veg-$cut_veg;
- $req_non=$tot_non-$cut_non;
- ?>
- //insert_mess_req
- <?php
- $month=$_POST['month'];
- $date=$_POST['date'];
- $req_veg=$_POST['req_veg'];
- $req_non=$_POST['req_non'];
- $query="insert into mess_req values('$month','$date','$req_non','$req_veg')";
- $result=mysql_query($query) or die(mysql_error());
- if($result)
- {
- header('Location: /adminHome.php');
- }
- ?>