Advertisement
Guest User

index

a guest
Sep 13th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.64 KB | None | 0 0
  1. <?php  
  2. //index.php
  3. $connect = mysqli_connect("", "", "", "");
  4. $connect->set_charset("utf8");
  5. $query = "SELECT * FROM card_chest_level_m2m";
  6. $result = mysqli_query($connect, $query);
  7.  ?>  
  8. <!DOCTYPE html>  
  9. <html>  
  10.  <head>  
  11.   <title>Karten Level Hinzufügen</title>  
  12.   <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>  
  13.   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  
  14.   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  
  15.  </head>  
  16.  <body>
  17. <br />
  18.   <div class="container" style="width:700px;">  
  19.    <div class="table-responsive">
  20.     <div align="right">
  21.      <center><button type="button" name="age" id="age" data-toggle="modal" data-target="#add_data_Modal" class="btn btn-warning">Level Hinzufügen</button></center>
  22.      <br />
  23.     </div>
  24.     <div id="employee_table">
  25.      <table class="table table-bordered">
  26.       <tr>
  27.        <th width="25%">Karte</th>
  28.        <th width="25%">Kiste</th>
  29.        <th width="25%">Level</th>      
  30.       </tr>
  31.       <?php
  32.       while($row = mysqli_fetch_array($result))
  33.       {
  34.       ?>
  35.       <tr>
  36.        <td><?php echo $row["KaID"]; ?></td>
  37.        <td><?php echo $row["KiID"]; ?></td>
  38.        <td><?php echo $row["LID"]; ?></td>
  39.       </tr>
  40.       <?php
  41.       }
  42.       ?>
  43.      </table>
  44.     </div>
  45.    </div>  
  46.   </div>
  47.  </body>  
  48. </html>  
  49.  
  50. <div id="add_data_Modal" class="modal fade">
  51.  <div class="modal-dialog">
  52.   <div class="modal-content">
  53.    <div class="modal-header">
  54.     <button type="button" class="close" data-dismiss="modal">&times;</button>
  55.     <h4 class="modal-title">Karten Level Hinzufügen</h4>
  56.    </div>
  57.    <div class="modal-body">
  58.     <form method="post" id="insert_form">
  59.      <label>Karte</label>
  60.      <select name="KaID" id="KaID" class="form-control">
  61.  
  62.         <option value="">Karte auswählen</option>
  63.         <?php
  64.         $query = "SELECT * FROM Card";
  65.         $result = mysqli_query($connect, $query);
  66.        
  67.         foreach ($result as $k4s) : ?>
  68.             <option value="<?php echo $k4s["KartenIDs"]; ?>"><?php echo $k4s["Card_Name"]; ?></option>
  69.         <?php endforeach; ?>
  70.  
  71.  
  72.  
  73.      </select>   
  74.      <br />
  75.      <label>Kiste</label>
  76.      <select name="KiID" id="KiID" class="form-control">
  77.  
  78.         <option value="">Kiste auswählen</option>
  79.         <?php
  80.         $query = "SELECT * FROM Chest";
  81.         $result = mysqli_query($connect, $query);
  82.        
  83.         foreach ($result as $ki4s) : ?>
  84.             <option value="<?php echo $ki4s["ChestIDs"]; ?>"><?php echo $ki4s["Chest_Name"]; ?></option>
  85.         <?php endforeach; ?>
  86.  
  87.  
  88.  
  89.      </select> 
  90.      <br />
  91.      <label>Level</label>
  92.      <input type="number" name="LID" id="LID" class="form-control" min="1" max="300" />
  93.      <br /> <center>
  94.      <input type="submit" name="insert" id="insert" value="Hinzufügen" class="btn btn-success" />
  95.     <button type="button" class="btn btn-default" data-dismiss="modal">Abbrechen</button></center>
  96.     </form>
  97.    </div>
  98.  
  99.   </div>
  100.  </div>
  101. </div>
  102.  
  103. <div id="dataModal" class="modal fade">
  104.  <div class="modal-dialog">
  105.   <div class="modal-content">
  106.    <div class="modal-header">
  107.     <button type="button" class="close" data-dismiss="modal">&times;</button>
  108.     <h4 class="modal-title">Karten Details</h4>
  109.    </div>
  110.    <div class="modal-body" id="employee_detail">
  111.    
  112.    </div>
  113.    <div class="modal-footer">
  114.     <button type="button" class="btn btn-default" data-dismiss="modal">zurück</button>
  115.    </div>
  116.   </div>
  117.  </div>
  118. </div>
  119.  
  120. <script>  
  121. $(document).ready(function(){
  122.  $('#insert_form').on("submit", function(event){  
  123.   event.preventDefault();  
  124.   if($('#KaID').val() == "")  
  125.   {  
  126.    alert("Karte muss ausgewählt sein");  
  127.   }  
  128.   else if($('#KiID').val() == '')  
  129.   {  
  130.    alert("Kiste muss ausgewählt sein");  
  131.   }  
  132.   else if($('#LID').val() == '')
  133.   {  
  134.    alert("Level muss angegeben sein");  
  135.   }
  136.    
  137.   else  
  138.   {  
  139.    $.ajax({  
  140.     url:"insert.php",  
  141.     method:"POST",  
  142.     data:$('#insert_form').serialize(),  
  143.     beforeSend:function(){  
  144.      $('#insert').val("Hinzufügen");  
  145.     },  
  146.     success:function(data){  
  147.      $('#insert_form')[0].reset();  
  148.      $('#add_data_Modal').modal('hide');  
  149.      $('#employee_table').html(data);  
  150.     }  
  151.    });  
  152.   }  
  153.  });
  154.  
  155.  
  156.  
  157.  
  158.  $(document).on('click', '.view_data', function(){
  159.   //$('#dataModal').modal();
  160.   var employee_id = $(this).attr("ID");
  161.   $.ajax({
  162.    url:"select.php",
  163.    method:"POST",
  164.    data:{employee_id:employee_id},
  165.    success:function(data){
  166.     $('#employee_detail').html(data);
  167.     $('#dataModal').modal('show');
  168.    }
  169.   });
  170.  });
  171. });
  172.  </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement