Hadi1989

Untitled

Jul 5th, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.11 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang = "en">
  3.     <head>
  4.         <meta charset = "UTF-8" name = "viewport" content = "width-device=width, initial-scale=1" />
  5.         <link rel = "stylesheet" type = "text/css" href = "css/bootstrap.css" />
  6.         <title>OOP PHP CRUD Operation</title>
  7.     </head>
  8. <body>
  9.     <nav class = "navbar navbar-default">
  10.         <div class = "container-fluid">
  11.             <a class = "navbar-brand" href = "">itsaudara</a>
  12.         </div>
  13.     </nav>
  14.     <div class = "row">
  15.         <div class = "col-md-3">
  16.         </div>
  17.         <div class = "col-md-6 well">
  18.             <h3 class = "text-primary">OOP PHP CRUD Operation Using MySQLi - Part 2</h3>
  19.             <hr style = "border-top:1px dotted #000;"/>
  20.             <form method  = "POST" class = "form-inline" action = "create.php">
  21.                 <div class = "form-group">
  22.                     <label>Firstname:</label>
  23.                     <input type  = "text" id = "firstname" name = "firstname" class = "form-control" required = "required"/>
  24.                 </div>
  25.                 <div class = "form-group">
  26.                     <label>Lastname:</label>
  27.                     <input type  = "text" id = "lastname" name = "lastname" class = "form-control" required = "required"/>
  28.                 </div>
  29.                 <div class = "form-group">
  30.                     <button name = "save" class = "btn btn-primary"><span class = "glyphicon glyphicon-plus"></span> Add</button>
  31.                 </div>
  32.             </form>
  33.             <br />
  34.             <table class = "table table-bordered alert-warning table-hover">
  35.                 <thead>
  36.                     <th>Firstname</th>
  37.                     <th>Lastname</th>
  38.                     <th>Action</th>
  39.                 </thead>
  40.                 <tbody>
  41.                 <?php
  42.                     require 'class.php';
  43.                     $conn = new db_class();
  44.                     $read = $conn->read();
  45.                     while($fetch = $read->fetch_array()){
  46.                 ?>
  47.                     <tr>
  48.                         <td><?php echo $fetch['firstname']?></td>
  49.                         <td><?php echo $fetch['lastname']?></td>
  50.                         <td><center><a class = "btn btn-warning update_mem_id" data-toggle = "modal" data-target = "#update_modal" name = "<?php echo $fetch['mem_id']?>"><span class = "glyphicon glyphicon-edit"></span> Update</a> | <a class = "btn btn-danger del_mem_id" name = "<?php echo $fetch['mem_id']?>" data-toggle = "modal" data-target="#del_modal"><span class = "glyphicon glyphicon-trash"></span> Delete</a></center></td>
  51.                     </tr>
  52.                 <?php
  53.                     }
  54.                 ?> 
  55.                 </tbody>
  56.             </table>
  57.         </div>
  58.     </div>
  59.  
  60. <!-- Modal -->
  61. <div class="modal fade" id="del_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  62.   <div class="modal-dialog" role="document">
  63.     <div class="modal-content">
  64.       <div class="modal-body">
  65.         <center><h4 class = "text-danger">Are you sure you want to delete this record?</h4></center>
  66.       </div>
  67.       <div class="modal-footer">
  68.         <button type = "button" class="btn btn-warning" data-dismiss="modal"><span class = "glyphicon glyphicon-remove"></span> No</button>
  69.         <button type = "button" class="btn btn-danger del_mem"><span class = "glyphicon glyphicon-trash"></span> Yes</button>
  70.       </div>
  71.     </div>
  72.   </div>
  73. </div>
  74. <div class="modal fade" id="update_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  75.   <div class="modal-dialog" role="document">
  76.     <div class="modal-content">
  77.         <div class = "modal-header">
  78.             <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  79.             <h3 class = "text-success modal-title">Update Member</h3>
  80.         </div>
  81.         <form method = "POST" action = "update_mem_query.php">
  82.         <div class="modal-body update">
  83.            
  84.       </div>
  85.       <div class="modal-footer">
  86.         <button class="btn btn-warning" name = "update"><span class = "glyphicon glyphicon-edit"></span> Save Changes</button>
  87.       </div>
  88.       </form>
  89.     </div>
  90.   </div>
  91. </div>
  92. </body>
  93. <script src = "js/jquery-3.1.1.js"></script>
  94. <script src = "js/bootstrap.js"></script>
  95. <script type = "text/javascript">
  96.     $(document).ready(function(){
  97.        
  98.         //Delete
  99.         $('.del_mem_id').on('click', function(){
  100.             $mem_id = $(this).attr('name');
  101.             $('.del_mem').on('click', function(){
  102.                 window.location = "delete_mem.php?mem_id=" + $mem_id;
  103.             });
  104.         });
  105.        
  106.         //Update
  107.         $('.update_mem_id').on('click', function(){
  108.             $mem_id = $(this).attr('name');
  109.             $('.update').load('mem_data.php?mem_id=' + $mem_id);
  110.         });
  111.     });
  112. </script>
  113. </html>
Advertisement
Add Comment
Please, Sign In to add comment