Advertisement
Guest User

Untitled

a guest
Feb 10th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.17 KB | None | 0 0
  1. <?php
  2. require_once '../config.php';
  3. $helper = new config();
  4. // echo $helper->url('gidilecek-uri');
  5. ?>
  6. <?php
  7. $hostname = "localhost";$username = "root";$password = "";$databaseName = "vmyo";
  8. $connect = mysqli_connect($hostname, $username, $password, $databaseName);
  9. $connect->set_charset("utf8");
  10. $query = "SELECT * FROM `kitap`";
  11. $result1 = mysqli_query($connect, $query);
  12. ?>
  13. <!DOCTYPE html>
  14. <html>
  15. <head>
  16. <meta charset="utf-8">
  17. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  18. <title></title>
  19. <?php include '../tumcssjs.php'; ?>
  20. </head>
  21. <body>
  22. <div class="container animated fadeIn" style="max-width: 1102px;">
  23. <div class="row">
  24. <form class="well form-horizontal" action=" " method="post" id="contact_form">
  25. <fieldset>
  26. <div class="col-md-4">
  27. <div class="form-group">
  28. <label class="col-md-4 control-label">Aldığı Kitap:</label>
  29. <div class="col-md-8 inputGroupContainer">
  30. <div class="input-group">
  31. <select class="form-control" name="kitapadi" id="kitapadi">
  32. <option value="">--Kitap Seçiniz--</option>
  33. <?php while($row1 = mysqli_fetch_array($result1)):;?>
  34. <option value="<?php echo $row1[0];?>"><?php echo $row1[3];?></option>
  35. <?php endwhile;?>
  36. </select>
  37. <i class="fa fa-spin fa-spinner" id="loader" style="display: none"></i>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="form-group">
  42. <label class="col-md-4 control-label">Barkod No:</label>
  43. <div class="col-md-8 inputGroupContainer">
  44. <div class="input-group">
  45. <span class="input-group-addon"><i class="glyphicon glyphicon-barcode"></i></span>
  46. <input name="barkodno" id="barkodno" placeholder="Barkod No" class="form-control" type="text">
  47. </div>
  48. </div>
  49. </div>
  50. <div class="form-group">
  51. <label class="col-md-4 control-label">Bölüm No:</label>
  52. <div class="col-md-8 inputGroupContainer">
  53. <div class="input-group">
  54. <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
  55. <input name="bolumno" id="bolumno" placeholder="Bilgisayar Bölümü: B001 " class="form-control" type="text">
  56. </div>
  57. </div>
  58. </div>
  59. </div><!-- col-md-4 bitiş -->
  60. </div>
  61.  
  62.  
  63. <script>
  64.  
  65. $('#kitapadi').on('change',function () {
  66.  
  67.  
  68. var kitap_id = $(this).val();
  69. if(kitap_id){
  70.  
  71.  
  72. $.ajax({
  73.  
  74. url:"<?php echo $helper->url("kitap/ajax.php"); ?>",
  75. type:"POST",
  76. cache:false,
  77. dataType:"json",
  78. data:{action:"getBookDetails",id:kitap_id},
  79. beforeSend:function(){
  80. $("#loader").show();
  81. },
  82. success:function(data){
  83. if(data !="hata")
  84. {
  85.  
  86. console.log(data);
  87. var d = jQuery.parseJSON(JSON.stringify(data));
  88. $('#barkodno').val(d.barkodno);
  89. $('#bolumno').val(d.bolumno);
  90.  
  91. }else{
  92. alert("İşleminiz gerçekleştirelemedi!");
  93. }
  94. $("#loader").hide();
  95. },
  96. error:function(err){
  97. console.log(data);
  98. }
  99.  
  100.  
  101.  
  102. });
  103.  
  104. }
  105.  
  106.  
  107. });
  108.  
  109. </script>
  110.  
  111. </body>
  112. </html>
  113.  
  114. <?php
  115.  
  116. $DB_host = "localhost";
  117. $DB_user = "root";
  118. $DB_pass = "";
  119. $DB_name = "vmyo";
  120.  
  121.  
  122. try
  123. {
  124. $DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
  125. $DB_con->exec("SET NAMES 'utf-8';SET CHARSET 'utf-8'");
  126. $DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  127.  
  128. }
  129. catch(PDOException $e)
  130. {
  131. echo $e->getMessage();
  132. }
  133.  
  134.  
  135.  
  136. if($_POST && $_POST["action"]=="getBookDetails"){
  137.  
  138. $kitap_id = $_POST['id'];
  139. //ilginç bi hata onlar boş geliyo
  140. $book = $DB_con->query("SELECT * from kitap where id='{$kitap_id}' ")->fetch(PDO::FETCH_ASSOC);
  141.  
  142. if($book){
  143.  
  144. echo json_encode($book);
  145. //print_r( $book );
  146.  
  147. }else{
  148. echo "error";
  149. }
  150.  
  151.  
  152. }
  153.  
  154. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement