nasoa

da

Nov 8th, 2013
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.76 KB | None | 0 0
  1. <?php
  2. if($domain!=='admin' && $domain!=='superadmin'){
  3. ?><script language="javascript">document.location.href="logout.php"</script><?php
  4. }
  5. ?>
  6. <?php
  7. if($_GET['mode']=='input'){
  8.  
  9. $id_siswa=htmlentities($_POST['id_siswa']);
  10. $id_kelas=htmlentities($_POST['id_kelas']);
  11.  
  12. $cek_query=mysql_query("select * from tbl_ruangan where id_siswa='$id_siswa' and id_kelas='$id_kelas'");
  13. $cek_query2=mysql_query("select * from tbl_ruangan where id_siswa='$id_siswa'");
  14. $cek_num=mysql_num_rows($cek_query);
  15. $cek_num2=mysql_num_rows($cek_query2);
  16.  
  17. if($cek_num!==0 || $cek_num2!==0){
  18. ?><script language="javascript">document.location.href="?page=jadwal_ruangkelas&status=4";</script><?php
  19. }else{
  20. $query=mysql_query("insert into tbl_ruangan values('','$id_siswa','$id_kelas')");
  21.  
  22. if($query){
  23. ?><script language="javascript">document.location.href="?page=jadwal_ruangkelas&status=1";</script><?php
  24. }
  25. }
  26. }
  27.  
  28. if($_GET['mode']=='delete'){
  29.  
  30. $id_ruangan=$_GET['id_ruangan'];
  31. $query=mysql_query("delete from tbl_ruangan where id_ruangan='$id_ruangan'");
  32. if($query){
  33. ?><script language="javascript">document.location.href="?page=jadwal_ruangkelas&status=2";</script><?php
  34. }
  35. }
  36.  
  37. if($_GET['mode']=='update'){
  38. $id_ruangan=$_POST['id_ruangan'];
  39.  
  40. $id_siswa=$_POST['id_siswa'];
  41. $id_kelas=$_POST['id_kelas'];
  42.  
  43. $cek_query=mysql_query("select * from tbl_ruangan where id_siswa='$id_siswa' and id_kelas='$id_kelas'");
  44. $cek_num=mysql_num_rows($cek_query);
  45.  
  46. if($cek_num!==0){
  47. ?><script language="javascript">document.location.href="?page=jadwal_ruangkelas&status=0";</script><?php
  48. }else{
  49.  
  50. $query=mysql_query("update tbl_ruangan set id_siswa='$id_siswa', id_kelas='$id_kelas' where id_ruangan='$id_ruangan'");
  51.  
  52. if($query){
  53. ?><script language="javascript">document.location.href="?page=jadwal_ruangkelas&status=3";</script><?php
  54. }else{
  55. echo mysql_error();
  56. }
  57. }
  58. }
  59.  
  60. if($_GET['mode']=='edit'){
  61. $id_ruangan=$_GET['id_ruangan'];
  62. $edit=mysql_query("select * from tbl_ruangan where id_ruangan='$id_ruangan'");
  63.  
  64. $data=mysql_fetch_array($edit);
  65. $id_siswa=$data['id_siswa'];
  66. $id_kelas=$data['id_kelas'];
  67. }
  68. ?>
  69.  
  70. <!-- start page-heading -->
  71. <div id="page-heading">
  72. <h1>Ruang Kelas</h1>
  73. </div>
  74. <!-- end page-heading -->
  75.  
  76. <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
  77. <tr>
  78. <th rowspan="3" class="sized"><img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
  79. <th class="topleft"></th>
  80. <td id="tbl-border-top">&nbsp;</td>
  81. <th class="topright"></th>
  82. <th rowspan="3" class="sized"><img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
  83. </tr>
  84. <tr>
  85. <td id="tbl-border-left"></td>
  86. <td>
  87. <!-- start content-table-inner ...................................................................... START -->
  88. <div id="content-table-inner">
  89.  
  90. <?php
  91. include "warning.php";
  92. ?>
  93.  
  94. <?php
  95. if($_GET['mode']=='edit'){
  96. ?><form action="?page=jadwal_ruangkelas&mode=update" method="post"><?php
  97. }else{
  98. ?><form action="?page=jadwal_ruangkelas&mode=input" method="post"><?php
  99. }
  100. ?>
  101.  
  102. <table border="0" width="100%" cellpadding="0" cellspacing="0">
  103. <tr valign="top">
  104. <td><!-- start step-holder -->
  105. <!-- end step-holder -->
  106. <!-- start id-form -->
  107. <table border="0" cellpadding="0" cellspacing="0" id="id-form">
  108. <tr>
  109. <th valign="top">Siswa</th>
  110. <td><select name="id_siswa" >
  111. <?php
  112. $siswa=mysql_query("select * from data_siswa order by nama_siswa asc");
  113. while($row1=mysql_fetch_array($siswa)){
  114. ?>
  115. <option value="<?php echo $row1['id_siswa'];?>" <?php if($row1['id_siswa']==$id_siswa){ echo 'selected';}?>><?php echo $row1['nama_siswa'];?> (<?php echo $row1['nis'];?>) </option>
  116. <?php
  117. }
  118. ?>
  119.  
  120. </select>
  121. </td>
  122. <td></td>
  123. </tr>
  124.  
  125. <tr>
  126. <th valign="top">Kelas</th>
  127. <td><select name="id_kelas" >
  128. <?php
  129. $kelas=mysql_query("select * from setup_kelas order by nama_kelas asc");
  130. while($row2=mysql_fetch_array($kelas)){
  131. ?>
  132. <option value="<?php echo $row2['id_kelas'];?>" <?php if($row2['id_kelas']==$id_kelas){ echo 'selected';}?>><?php echo $row2['nama_kelas'];?></option>
  133. <?php
  134. }
  135. ?>
  136.  
  137. </select>
  138. </td>
  139. <td></td>
  140. </tr>
  141.  
  142. <tr>
  143. <th>&nbsp;</th>
  144. <td valign="top">
  145. <input type="hidden" name="id_ruangan" value="<?php echo $_GET['id_ruangan'];?>">
  146. <input type="submit" name="submit" onClick="return confirm('Apakah Anda yakin?')" value="" class="form-submit" />
  147. <input type="reset" value="" class="form-reset" />
  148. </td>
  149. <td></td>
  150. </tr>
  151. </table>
  152. <!-- end id-form -->
  153. </td>
  154. <td><!-- start related-activities -->
  155. </td>
  156. </tr>
  157. <tr>
  158. <td><img src="images/shared/blank.gif" width="695" height="1" alt="blank" /></td>
  159. <td></td>
  160. </tr>
  161. </table>
  162. </form>
  163.  
  164. <p><em>* Satu siswa hanya untuk Satu Ruang Kelas</em>
  165. <!-- start product-table ..................................................................................... -->
  166. </p>
  167. <p>&nbsp;</p>
  168.  
  169.  
  170. <?php
  171. //************awal paging************//
  172. $query=mysql_query("select * from tbl_ruangan ruangan, setup_kelas kelas, data_siswa siswa where ruangan.id_kelas=kelas.id_kelas and ruangan.id_siswa=siswa.id_siswa order by id_ruangan asc");
  173. $get_pages=mysql_num_rows($query); //dapatkan jumlah semua data
  174.  
  175. if ($get_pages>$entries) //jika jumlah semua data lebih banyak dari nilai awal yang diberikan
  176. {
  177. ?>Halaman : <?php
  178. $pages=1;
  179. while($pages<=ceil($get_pages/$entries))
  180. {
  181. if ($pages!=1)
  182. {
  183. echo " | ";
  184. }
  185. ?>
  186. <!--Membuat link sesuai nama halaman-->
  187. <a href="?page=jadwal_ruangkelas&halaman=<?php echo ($pages-1); ?> " style="text-decoration:none"><font size="2" face="verdana" color="#009900"><?php echo $pages; ?></font></a>
  188. <?php
  189. $pages++;
  190. }
  191.  
  192. }else{
  193. $pages=1;
  194. }
  195.  
  196. //**************akhir paging*****************//
  197. ?>
  198. </font>
  199. <?php
  200. $page=(int)$_GET['halaman'];
  201. $offset=$page*$entries;
  202.  
  203. //menampilkan data dengan menggunakan limit sesuai parameter paging yang diberikan
  204. $result=mysql_query("select * from tbl_ruangan ruangan, setup_kelas kelas, data_siswa siswa where ruangan.id_kelas=kelas.id_kelas and ruangan.id_siswa=siswa.id_siswa order by id_ruangan asc limit $offset,$entries"); //output
  205. ?>
  206.  
  207. <form id="mainform" action="">
  208. <table class="table">
  209. <tr>
  210. <td><a href="">Nomor</a><td>
  211. <td><a href="">Nama Siswa</a><td>
  212. <td><a href="">NIS</a><td>
  213. <td><a href="">Kelas</a><td>
  214. <td><a href="">Aksi</a><td>
  215. </tr>
  216. <?php
  217. $no=0;
  218. while($row=mysql_fetch_array($result)){
  219. ?>
  220. <tr class="table">
  221. <td><?php echo $offset=$offset+1;?></td>
  222. <td><?php echo $row['nama_siswa'];?></td>
  223. <td><?php echo $row['nis'];?></td>
  224. <td><?php echo $row['nama_kelas'];?></td>
  225. <td class="options-width">
  226. <a href="?page=jadwal_ruangkelas&mode=delete&id_ruangan=<?php echo $row['id_ruangan'];?>" onclick="return confirm('Apakah Anda yakin?')" title="Delete" class="icon-2 info-tooltip"></a>
  227. <a href="?page=jadwal_ruangkelas&mode=edit&id_ruangan=<?php echo $row['id_ruangan'];?>" title="Edit" class="icon-5 info-tooltip"></a>
  228. </td>
  229. </tr>
  230. <?php
  231. }
  232. ?>
  233. </table>
  234. TOTAL DATA : <?php echo $get_pages;?>
  235. <!-- end product-table................................... -->
  236. </form>
  237.  
  238.  
  239.  
  240. <div class="clear"></div>
  241.  
  242. </div>
  243. <!-- end content-table-inner ............................................END -->
  244. </td>
  245. <td id="tbl-border-right"></td>
  246. </tr>
  247. <tr>
  248. <th class="sized bottomleft"></th>
  249. <td id="tbl-border-bottom">&nbsp;</td>
  250. <th class="sized bottomright"></th>
  251. </tr>
  252. </table>
Advertisement
Add Comment
Please, Sign In to add comment