PageRenderTime 27ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  1. // mess_cut
  2. <?php
  3. $time=date("H:i");
  4. if($time>$t)
  5. {
  6. header('Location: /timeout.php');
  7. }
  8. ?>
  9. //mess_req_day
  10. <?php
  11. $q1=mysql_query("select count(uid) from students") or die(mysql_error());
  12. $q2=mysql_query("select count(id) from guest") or die(mysql_error());
  13. $q3=mysql_query("select count(id) from staff") or die(mysql_error());
  14. $r1=mysql_fetch_array($q1) or die(mysql_error());
  15. $r2=mysql_fetch_array($q2) or die(mysql_error());
  16. $r3=mysql_fetch_array($q3) or die(mysql_error());
  17. $c1=$r1['count'];
  18. $c2=$r2['count'];
  19. $c3=$r3['count'];
  20. $strength=($c1+$c2+$c3)*$mess_days;
  21. $tot_no=$c1+$c2+$c3;
  22. $q1v=mysql_query("select count(uid) from students where veg_non='YES'") or die(mysql_error());
  23. $q2v=mysql_query("select count(id) from guest where veg_non='YES'") or die(mysql_error());
  24. $q3v=mysql_query("select count(id) from staff where veg_non='YES'") or die(mysql_error());
  25. $r1v=mysql_fetch_array($q1v) or die(mysql_error());
  26. $r2v=mysql_fetch_array($q2v) or die(mysql_error());
  27. $r3v=mysql_fetch_array($q3v) or die(mysql_error());
  28. $c1v=$r1v['count'];
  29. $c2v=$r2v['count'];
  30. $c3v=$r3v['count'];
  31. $tot_veg=$c1v+$c2v+$c3v;
  32. $q1n=mysql_query("select count(uid) from students where veg_non='NO'") or die(mysql_error());
  33. $q2n=mysql_query("select count(id) from guest where veg_non='NO'") or die(mysql_error());
  34. $q3n=mysql_query("select count(id) from staff where veg_non='NO'") or die(mysql_error());
  35. $r1n=mysql_fetch_array($q1n) or die(mysql_error());
  36. $r2n=mysql_fetch_array($q2n) or die(mysql_error());
  37. $r3n=mysql_fetch_array($q3n) or die(mysql_error());
  38. $c1n=$r1n['count'];
  39. $c2n=$r2n['count'];
  40. $c3n=$r3n['count'];
  41. $tot_non=$c1n+$c2n+$c3n;
  42. $cut_veg=0;
  43. $cut_non=0;
  44. $date=date('Y-m-d');
  45. $result=mysql_query("select * from student where veg_non='YES'") or die(mysql_error());
  46. while($row=mysql_fetch_array($result))
  47. {
  48. $id=$row['uid'];
  49. $result1=mysql_query("select * from mess_cut where id='$id'") or die(mysql_error());
  50. while($row1=mysql_fetch_array($result1))
  51. {
  52. if(($date>=$row1['ffrom'])&&($date<=$row1['tto']))
  53. {
  54. $cut_veg++;
  55. break;
  56. }
  57. }
  58. }
  59. $result1=mysql_query("select * from student where veg_non='NO'") or die(mysql_error());
  60. while($row1=mysql_fetch_array($result1))
  61. {
  62. $id=$row1['uid'];
  63. $result2=mysql_query("select * from calc_veg where id='$id'") or die(mysql_error());
  64. while($row2=mysql_fetch_array($result2))
  65. {
  66. if(($date>=$row2['ffrom'])&&($date<=$row2['tto']))
  67. {
  68. $cut_veg--;
  69. break;
  70. }
  71. }
  72. $result3=mysql_query("select * from mess_cut where id='$id'") or die(mysql_error());
  73. while($row3=mysql_fetch_array($result3))
  74. {
  75. if(($date>=$row3['ffrom'])&&($date<=$row3['tto']))
  76. {
  77. $cut_non++;
  78. break;
  79. }
  80. }
  81. }
  82. $req_veg=$tot_veg-$cut_veg;
  83. $req_non=$tot_non-$cut_non;
  84. ?>
  85. //insert_mess_req
  86. <?php
  87. $month=$_POST['month'];
  88. $date=$_POST['date'];
  89. $req_veg=$_POST['req_veg'];
  90. $req_non=$_POST['req_non'];
  91. $query="insert into mess_req values('$month','$date','$req_non','$req_veg')";
  92. $result=mysql_query($query) or die(mysql_error());
  93. if($result)
  94. {
  95. header('Location: /adminHome.php');
  96. }
  97. ?>