Advertisement
GWibisono

caraku yg sederhana tp jadikan solusi terakhir

Jun 15th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.26 KB | None | 0 0
  1. <?php
  2. include '../config/koneksi.php';
  3. $file=$_SERVER['PHP_SELF'];
  4. include "class_paging.php";
  5. $p = new Paging;
  6. $batas = 10;
  7. $posisi = $p->cariPosisi($batas);
  8.  
  9. if($_GET['view'])
  10. {
  11.     $sql="...";
  12.     /*
  13.     isi .... dengan query periksa2
  14.     */
  15.     $q=mysql_query($sql);
  16.     if(mysql_num_rows($q)==0){
  17.         $tombol='<input type="submit" name="button" id="button" value="Simpan">';
  18.         $_GET['view']=='pesan'?$s='':$s=$tombol;
  19.          
  20.     }else{
  21.         $tombol='<input type="button" name="button" id="button" disable value="Simpan">';
  22.         $_GET['view']=='pesan'?$s='sudah terisi':$s=$tombol;
  23.    
  24.     }
  25.  
  26.  
  27. die($s);
  28. }
  29.  
  30. ?><head>
  31. <link type="text/css" href="../js/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
  32. <script type="text/javascript" src="../js/jquery-1.7.2.js"></script>
  33. <script type="text/javascript" src="../js/jquery-ui-1.8.20.cust*m.min.js"></script>
  34.  
  35. <script type="text/javascript" src="../js/jquery.validate.js"></script>
  36. <script language="javascript">
  37. $(document).ready(function()
  38. {
  39.     $("#kamarc").change(function(){
  40.         $("#kamarc option:selected").each(function () {                
  41.                 id=$(this).val();
  42.                 //alert(id);
  43.         });
  44.         url2='?view=tombol&id='+id+'&t1=<?=mktime();?>';    
  45.         $.get(url2, function(data) {
  46.            $('#hasil').html(data);
  47.         });
  48.         url2='?view=pesan&id='+id+'&t1=<?=mktime();?>';    
  49.         $.get(url2, function(data) {
  50.            $('#msgbox').html(data);
  51.         });
  52.    
  53.     });
  54.  
  55.     $("#kamarc").blur(function()
  56.     {
  57.         //remove all the class add the messagebox classes and start fading
  58.         $("#msgbox").removeClass().text('Checking...').fadeIn("slow");
  59.         //check the username exists or not from ajax
  60.         $.post("cek_kamar.php",{no_kamar:$(this).val() } ,function(data)
  61.         {
  62.             if(data=="no") //if username not avaiable
  63.             {
  64.                 $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
  65.                 {
  66.                 //add message and change the class of the box and start fading
  67.                 $(this).html("Kamar Sudah Di tempati").fadeTo(900,1);
  68.                 });
  69.             }
  70.             elseif(data=="yes") //if username not avaiable
  71.             {
  72.                 $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
  73.                 {
  74.                     //add message and change the class of the box and start fading
  75.                     $(this).html("Kamar Masih Kosong").fadeTo(900,1);
  76.  
  77.                 });
  78.             }
  79.         });
  80.  
  81.     });
  82.  
  83. });
  84. </script>
  85. <script>
  86. $(document).ready(function(){
  87.     $("#penghuni").validate({
  88.     rules: {
  89.     nama: {
  90.     required: true,
  91.     minlength: 3
  92.     },
  93.     pass:{
  94.     required:true,
  95.     minlength:5
  96.     },
  97.     kamarc:{
  98.  
  99.     required: if(data=="no")
  100.     },
  101.  
  102.     },
  103.     messages: {
  104.     nama: {
  105.     required: "Kolom nama harus diisi",
  106.     minlength: "Kolom nama minimal terdiri 3 karakter"
  107.     },
  108.     pass: {
  109.     required: "Kolom password harus diisi",
  110.     minlength: "Kolom password minimal terdiri 5 karakter"
  111.     },
  112.  
  113.     },
  114.     submitHandler: function(form){
  115.     $(form).ajaxSubmit({
  116.     dataType: "xml",
  117.     resetForm: true,
  118.     success: function(data){
  119.     alert("Data telah disimpan");
  120.     }
  121.     });
  122.     }
  123.     });
  124. });
  125.  
  126. $(document).ready(function()
  127. {
  128.     $("#kamar").blur(function()
  129.     {
  130.     //remove all the class add the messagebox classes and start fading
  131.     $("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
  132.     //check the username exists or not from ajax
  133.     $.post("cek_kamar.php",{no_kamar:$(this).val() } ,function(data)
  134.     {
  135.     if(data=='no') //if username not avaiable
  136.     {
  137.     $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
  138.     {
  139.     //add message and change the class of the box and start fading
  140.     $(this).html('Nama Sudah Ada').addClass('messageboxerror').fadeTo(900,1);
  141.     });
  142.     }
  143.     else
  144.     {
  145.     $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
  146.     {
  147.     //add message and change the class of the box and start fading
  148.     $(this).html('Nama Tersedia ').addClass('messageboxok').fadeTo(900,1);
  149.     $(this).focus();
  150.     });
  151.  
  152.     }
  153.  
  154.     });
  155.  
  156.     });
  157.  
  158. });
  159. </script>
  160.  
  161. </head>
  162. <body>
  163.  
  164. <h2>Input Penghuni </h2>
  165. <form action="penghunisim.php" method="post" enctype="multipart/form-data" name="penghuni" id="penghuni" class="cmxForm">
  166. <table width="725" border=0>
  167. <tr>
  168. <td width="213">Nama</td>
  169. <td width="502">:
  170. <input name="nama" type="text" id="cnama" class="required" title="nama tidak boleh kosong!"></td>
  171. </tr>
  172. <tr>
  173. <td>User</td>
  174. <td>:
  175. <input name="user" type="text" id="user" class="required" title="user tidak boleh kosong!"></td>
  176. </tr>
  177. <tr>
  178. <td>Password</td>
  179. <td>:
  180. <input name="pass" type="text" id="pass" class="required" title="password harus diisi!"></td>
  181. </tr>
  182. <tr>
  183. <td>Alamat Asli</td>
  184. <td>:
  185. <textarea name="alamat" id="alamat" cols="45" rows="5"></textarea></td>
  186. </tr>
  187. <tr>
  188. <td>No.Telp</td>
  189. <td>:
  190. <input type="text" name="notelp" id="notelp"></td>
  191. </tr>
  192. <tr>
  193. <td>Kampus</td>
  194. <td>:
  195. <select name="kampus" id="kampus" class="required" title="kampus harus dipilih!">
  196. <option> </option>
  197. <?php include '../config/koneksi.php';
  198. $tampil=mysql_query("select * from kampus order by id_kampus");
  199. while($r=mysql_fetch_array($tampil)){
  200. echo "<option value=$r[id_kampus]>$r[kampus]</option>";
  201. } ?>
  202. </select></td>
  203. </tr>
  204. <tr>
  205. <td>Jurusan</td>
  206. <td>:
  207. <select name="jurusan" id="jurusan" class="required" title="jurusan wajib diisi !">
  208. <option></option>
  209. <?php include '../config/koneksi.php';
  210. $tampil=mysql_query("select * from jurusan order by kd_jurusan");
  211. while($r=mysql_fetch_array($tampil)){
  212. echo "<option value=$r[kd_jurusan]>$r[jurusan]</option>";
  213. } ?>
  214. </select></td>
  215. </tr>
  216. <tr>
  217. <td>Tgl Masuk Asrama</td>
  218. <td>:
  219. <select name="tanggal" class="required" title=" diisi!">
  220. <option> </option>
  221. <?php
  222. for($hr=1; $hr<32 ; $hr++)
  223. {
  224. echo"<option value='$hr'>$hr</option>";
  225. }
  226. ?>
  227. </select>
  228. -
  229. <select name="bulan" class="required" title="diisi dulu">
  230. <option> </option>
  231. <option value="01">Januari</option>
  232. <option value="02">Februari</option>
  233. <option value="03">Maret</option>
  234. <option value="04">April</option>
  235. <option value="05">Mei</option>
  236. <option value="06">Juni</option>
  237. <option value="07">Juli</option>
  238. <option value="08">Agustus</option>
  239. <option value="09">September</option>
  240. <option value="10">Oktober</option>
  241. <option value="11">November</option>
  242. <option value="12">Desember</option>
  243. </select>
  244. -
  245. <select name="tahun" class="required" title="diisi dulu">
  246. <option> </option>
  247. <?php
  248. $year=date("Y");
  249. for($th=2007; $th<2015; $th++)
  250. {
  251. echo" <option value='$th'>$th</option>";
  252. }
  253. ?>
  254. </select></td>
  255. </tr>
  256. <tr>
  257. <td>Tgl Masuk Kuliah</td>
  258. <td>:
  259. <select name="tanggal2" class="required" title=" diisi!">
  260. <option> </option>
  261. <?php
  262. for($hr=1; $hr<32 ; $hr++)
  263. {
  264. echo"<option value='$hr'>$hr</option>";
  265. }
  266. ?>
  267. </select>
  268. -
  269. <select name="bulan2" class="required" title="diisi dulu">
  270. <option> </option>
  271. <option value="01">Januari</option>
  272. <option value="02">Februari</option>
  273. <option value="03">Maret</option>
  274. <option value="04">April</option>
  275. <option value="05">Mei</option>
  276. <option value="06">Juni</option>
  277. <option value="07">Juli</option>
  278. <option value="08">Agustus</option>
  279. <option value="09">September</option>
  280. <option value="10">Oktober</option>
  281. <option value="11">November</option>
  282. <option value="12">Desember</option>
  283. </select>
  284. -
  285. <select name="tahun2" class="required" title="diisi dulu">
  286. <option> </option>
  287. <?php
  288. $year=date("Y");
  289. for($th=2007; $th<2015; $th++)
  290. {
  291. echo" <option value='$th'>$th</option>";
  292. }
  293. ?>
  294. </select></td>
  295. </tr>
  296. <tr>
  297. <td>Kamar</td>
  298. <td>:
  299.     <select name="kamar" id="kamarc" class="required" title="kamar diisi !">
  300.     <option></option>
  301.     <?php include '../config/koneksi.php';
  302.     $tampil=mysql_query("select * from kamar order by no_kamar");
  303.     while($r=mysql_fetch_array($tampil)){
  304.         echo "<option value=$r[no_kamar]>$r[no_kamar]</option>";
  305.     } ?>
  306.     </select>
  307.     <span id="msgbox" style="display:none"></span>
  308. </td>
  309. </tr>
  310. <tr>
  311. <td>Foto</td>
  312. <td>:
  313. <input name="foto" type="file" id="foto" class="required" title="foto wajib diisi"></td>
  314. </tr>
  315. <tr>
  316. <td>&nbsp;</td>
  317. <td><div id='hasil'>
  318. <input type="button" name="button" id="button" value="Simpan" disable >
  319. </div></td>
  320. </tr>
  321. </table>
  322. <hr>
  323. </form>
  324. </div>
  325.  
  326.  
  327. </body>
  328. <h2>Data Penghuni</h2>
  329.  
  330. <table width="576" border="1">
  331.  
  332.  
  333. <tr>
  334. <td width="47" align="center"><strong>No</strong></td>
  335. <td width="96" align="center"><strong>No ID </strong></td>
  336. <td width="84" align="center"><strong>Nama</strong></td>
  337. <td width="110" align="center"><strong>No Kamar </strong></td>
  338. <td align="center" colspan="4"><strong>Aksi</strong></td>
  339. </tr>
  340. <?php
  341.  
  342.  
  343.  
  344. $sql="SELECT * from penghuni where status='penghuni' order by no_kamar limit $posisi,$batas";
  345. $qry =mysql_query($sql);
  346. $no=$posisi+1;
  347. while($r=mysql_fetch_array($qry)){
  348. $ni++;
  349. ?>
  350. <tr>
  351. <td align="center"><?php echo $ni ?>.</td>
  352. <td align="center"><?php echo $r[id_penghuni] ?></td>
  353. <td><?php echo $r[nama] ?></td>
  354. <td align="center"><?php echo $r[no_kamar] ?></td>
  355.  
  356. <td width="115" align="center"><a href="media.php?p=penghunidet&amp;id=<?php echo $r[id_penghuni] ?>">Detail</a></td>
  357. <td width="84" align="center"><a href="penghunidel.php?id=<?php echo $r[id_penghuni] ?>">Hapus</a></td>
  358. <td width="84" align="center"><a href="media.php?p=penghunieditalum&id=<?php echo $r[id_penghuni] ?>">Alumni</a></td>
  359. </tr>
  360. <?php } ?>
  361.  
  362. </table>
  363.  
  364. <?php
  365.  
  366. $jmldata = mysql_num_rows(mysql_query("SELECT * FROM penghuni"));
  367. $jmlhalaman = $p->jumlahHalaman($jmldata, $batas);
  368. $linkHalaman = $p->navHalaman($_REQUEST[halaman], $jmlhalaman);
  369. echo $linkHalaman;
  370. ?>
  371. <p>&nbsp;</p>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement