aries_

cari

May 31st, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.53 KB | None | 0 0
  1. <?php
  2. include 'config/konek.php';
  3. echo "<script type='text/javascript'>
  4. function cek_tipe(val){
  5. if(val=='1'){
  6. document.getElementById('cari_tanggal').style.display='block';
  7. document.getElementById('cari_materi').value='';
  8. document.getElementById('cari_materi').style.display='none';
  9. }else if(val=='2'){
  10. document.getElementById('cari_materi').style.display='block';
  11. document.getElementById('cari_tanggal').value='';
  12. document.getElementById('cari_tanggal').style.display='none';
  13. }
  14. }
  15. </script>";
  16.  
  17.  
  18.  
  19. echo "<h1><center>Training</center></h1>";
  20. echo "<form name='f1' method=POST action=?module=cari>
  21. <input type='radio' name='pilih' id='pilih' value='1' onclick=\"cek_tipe(this.value);\"> Tanggal
  22. <input type='radio' name='pilih' id='pilih' value='2' onclick=\"cek_tipe(this.value);\"> Materi
  23. <br>
  24. <div id='cari_tanggal' style='display:none;'>Cari Tanggal Mulai : <input type='text' name='tanggal' size='10'></div>
  25. <div id='cari_materi' style='display:none;'>Cari Materi : <input type='text' name='materi' size='10'></div>
  26. <input type='submit' name='cari' value='Cari'>
  27. </form>";
  28.  
  29. if ($_POST[materi]== NULL) {
  30.  
  31. $cari =mysql_query ("select * from plan where TGL_MULAI = '$_POST[tanggal]'");
  32. echo "<table border=1>
  33.  
  34.    <tr><th>Kode Plan</th>
  35.    <th>NAMA TRAINING</th>
  36.    <th>LC</th><th>Instruktur</th>
  37.    <th>Ubis</th><th>Angkatan</th>
  38.    <th>Tanggal Mulai</th>
  39.    <th>Tanggal akhir</th>
  40.    <th>Anggaran</th>
  41.    <th>Peserta</th></tr>";
  42.  
  43. $i=1;
  44. while ($r=mysql_fetch_array($cari)){
  45.    echo " <tr><td>$r[KODE_PLAN]</td><td>$r[NAMA_M_TRAINING]</td><td>$r[KODE_LC]</td><td>$r[KODE_INST]</td><td>$r[KODE_UBIS]</td><td>$r[ANGKATAN]</td><td>$r[TGL_MULAI]</td><td>$r[TGL_AKHIR]</td><td>$r[ANGGARAN]</td><td>$r[PST]</td></tr>";
  46.    $i++;
  47. }
  48. echo "</table>";
  49. }
  50. else if ($_POST[tanggal]== NULL ) {
  51. $cari = trim(strtolower($_POST['materi']));
  52. $sql="SELECT * FROM plan WHERE lower(NAMA_M_TRAINING) LIKE '%''$cari''%'";
  53. $r=mysql_query ($sql)or die(mysql_error());
  54. //echo $cari;
  55. echo "<table border=1>
  56.  
  57.    <tr><th>Kode Plan</th>
  58.    <th>NAMA TRAINING</th>
  59.    <th>LC</th><th>Instruktur</th>
  60.    <th>Ubis</th><th>Angkatan</th>
  61.    <th>Tanggal Mulai</th>
  62.    <th>Tanggal akhir</th>
  63.    <th>Anggaran</th>
  64.    <th>Peserta</th></tr>";
  65.  
  66.  
  67. while ($t=mysql_fetch_array($r)){
  68.    echo " <tr><td>$r[KODE_PLAN]</td><td>$r[NAMA_M_TRAINING]</td><td>$r[KODE_LC]</td><td>$r[KODE_INST]</td><td>$r[KODE_UBIS]</td><td>$r[ANGKATAN]</td><td>$r[TGL_MULAI]</td><td>$r[TGL_AKHIR]</td><td>$r[ANGGARAN]</td><td>$r[PST]</td></tr>";
  69.  
  70. }
  71. echo "</table>";
  72. }
  73. ?>
Advertisement
Add Comment
Please, Sign In to add comment