Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once '../config.php';
- $helper = new config();
- // echo $helper->url('gidilecek-uri');
- ?>
- <?php
- $hostname = "localhost";$username = "root";$password = "";$databaseName = "vmyo";
- $connect = mysqli_connect($hostname, $username, $password, $databaseName);
- $connect->set_charset("utf8");
- $query = "SELECT * FROM `kitap`";
- $result1 = mysqli_query($connect, $query);
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title></title>
- <?php include '../tumcssjs.php'; ?>
- </head>
- <body>
- <div class="container animated fadeIn" style="max-width: 1102px;">
- <div class="row">
- <form class="well form-horizontal" action=" " method="post" id="contact_form">
- <fieldset>
- <div class="col-md-4">
- <div class="form-group">
- <label class="col-md-4 control-label">Aldığı Kitap:</label>
- <div class="col-md-8 inputGroupContainer">
- <div class="input-group">
- <select class="form-control" name="kitapadi" id="kitapadi">
- <option value="">--Kitap Seçiniz--</option>
- <?php while($row1 = mysqli_fetch_array($result1)):;?>
- <option value="<?php echo $row1[0];?>"><?php echo $row1[3];?></option>
- <?php endwhile;?>
- </select>
- <i class="fa fa-spin fa-spinner" id="loader" style="display: none"></i>
- </div>
- </div>
- </div>
- <div class="form-group">
- <label class="col-md-4 control-label">Barkod No:</label>
- <div class="col-md-8 inputGroupContainer">
- <div class="input-group">
- <span class="input-group-addon"><i class="glyphicon glyphicon-barcode"></i></span>
- <input name="barkodno" id="barkodno" placeholder="Barkod No" class="form-control" type="text">
- </div>
- </div>
- </div>
- <div class="form-group">
- <label class="col-md-4 control-label">Bölüm No:</label>
- <div class="col-md-8 inputGroupContainer">
- <div class="input-group">
- <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
- <input name="bolumno" id="bolumno" placeholder="Bilgisayar Bölümü: B001 " class="form-control" type="text">
- </div>
- </div>
- </div>
- </div><!-- col-md-4 bitiş -->
- </div>
- <script>
- $('#kitapadi').on('change',function () {
- var kitap_id = $(this).val();
- if(kitap_id){
- $.ajax({
- url:"<?php echo $helper->url("kitap/ajax.php"); ?>",
- type:"POST",
- cache:false,
- dataType:"json",
- data:{action:"getBookDetails",id:kitap_id},
- beforeSend:function(){
- $("#loader").show();
- },
- success:function(data){
- if(data !="hata")
- {
- console.log(data);
- var d = jQuery.parseJSON(JSON.stringify(data));
- $('#barkodno').val(d.barkodno);
- $('#bolumno').val(d.bolumno);
- }else{
- alert("İşleminiz gerçekleştirelemedi!");
- }
- $("#loader").hide();
- },
- error:function(err){
- console.log(data);
- }
- });
- }
- });
- </script>
- </body>
- </html>
- <?php
- $DB_host = "localhost";
- $DB_user = "root";
- $DB_pass = "";
- $DB_name = "vmyo";
- try
- {
- $DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
- $DB_con->exec("SET NAMES 'utf-8';SET CHARSET 'utf-8'");
- $DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- if($_POST && $_POST["action"]=="getBookDetails"){
- $kitap_id = $_POST['id'];
- //ilginç bi hata onlar boş geliyo
- $book = $DB_con->query("SELECT * from kitap where id='{$kitap_id}' ")->fetch(PDO::FETCH_ASSOC);
- if($book){
- echo json_encode($book);
- //print_r( $book );
- }else{
- echo "error";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement