Advertisement
cdsatrian

rev A

Dec 5th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. <?php /***** index.php *****/ ?>
  2. <?php
  3. $jml=isset($_GET['jml'])?(!empty$_GET['jml']?$_GET['jml']:2):2;
  4. ?>
  5. <script language='javascript' src='ajax.js'></script>
  6. <form>
  7. <input type='hidden' name='jml' value='<?php echo $jml;?>'>
  8. <?php
  9. for($n=1;$n<=$jml;$n++)
  10. {
  11. echo "<div class='textbox'>"
  12.      ."<input type='text' name='nim$n' placeholder='masukkan nim' id='searching$n' onkeyup='nim(this)' />"
  13.      ."<div id='pencariannim'></div>
  14.     ."</div>";
  15. }
  16. ?>
  17. </form>
  18.  
  19.  
  20. <?php /*******ajax.js*******/ ?>
  21. //pencarian nim
  22. function nim(myparam){
  23.   var obj=myparam.nextSibling;
  24.   var url='proses_ajax_ceknim.php?searching='+myparam.value;
  25.   while(obj.nodeType!=1){
  26.     obj=obj.nextSibling;
  27.   }
  28.   xmlhttp.open("GET", url);
  29.   xmlhttp.onreadystatechange = function() {
  30.     if ( xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
  31.       obj.innerHTML = xmlhttp.responseText;
  32.     } else {
  33.       obj.innerHTML = "<div align ='center'><img src='img/loading.gif' alt='Loading' />Loading...!!!</div>";
  34.     }
  35.   }
  36.   xmlhttp.send(null);
  37. }
  38.  
  39.  
  40. <?php /**** Proses_ajax_ceknim.php ***/ ?>
  41. <?php
  42. $key=$_GET['searching'];
  43. $result=mysql_query("select * from tblmhs where nim like '%$key%'",$koneksi);
  44. $get_pages=mysql_num_rows($result);
  45. if ($get_pages){
  46.   $row=mysql_fetch_array($result);
  47.   $nim=$row['nim'];
  48.   echo"benar";
  49. }
  50. else
  51. {
  52.   echo"<br><b>Belum ada data!!</b>";
  53. }
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement