I have defined Three php file where first as function.php , categories.php and view_all_categories.php
Function.php includes code to delete the row from variables value passed from categories.php. Category.php includes view_all_categories.php inside. When clicked on Delete Button, Modal Box appears and on Confirmation, it doesn't delete the corresponding row. Please Help
Here is the Code for Category.php
<?php include"includes/delete_modal.php"; ?>
    <div id="wrapper">
        <!-- Navigation -->
        <?php include"includes/admin_navigation.php"; ?>
         
  
       
        <div id="page-wrapper">
            <div class="container-fluid">
         
                <div class="row">
                        
                        <div class="col-xs-6">
                            <table class="table table-hover table-bordered">
                                <thead class="thead-dark">
                                    <tr>
                                        <th>Id</th>
                                        <th>Category Title</th>
                                        <th>Options</th>
                                    </tr>
                                </thead>
                                <tbody>
                                   <?php  //Displasy table from categories
                                    include "includes/view_all_categories.php";?>
                                    
                                    
                                <?php  //delete categories
                                 delete_categories();
                                ?>
                                 
                                </tbody>
                            </table>
                            
                        </div>
                    </div>
           
                    
                    
                </div>
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->
        </div>
        <!-- /#page-wrapper -->
    </div>
    <!-- /#wrapper -->
    
    <script>
  $('#myModal').on('show.bs.modal', function (e) {
 
     $(this).find('.modal_delete_link').attr('href', $(e.relatedTarget).data('href'));
 });
</script>
  Similarly code inside function.php is
function delete_categories(){
    global $connection;
    if(isset($_GET['delete'])){
    $del_id = $_GET['delete'];
    $query = "DELETE FROM categories WHERE cat_id = $del_id";
    $del_cat = mysqli_query($connection,$query);
    $query = "DELETE FROM posts WHERE post_category_id=$del_id";
    $del_category_rel_post = mysqli_query($connection,$query);
    header("Location: categories.php");
    }
and view_all_categories.php file include
<?php
$query = "SELECT * FROM categories";
$get_categories = mysqli_query($connection, $query);
while($row = mysqli_fetch_assoc($get_categories)){
$cat_id = $row['cat_id'];
$cat_title = $row['cat_title'];
echo "<tr><td>{$cat_id}</td><td>{$cat_title}</td>
<td><a class='btn btn-danger' data-toggle='modal' data-target='#myModal' data-href='categories.php?delete=$cat_id' href='javascript:void(0)'>Delete</a> <a class='btn btn-primary' href='categories.php?update={$cat_id}'>Update</a></td></tr>";
}
?>and delete_modal.php has
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal Content -->
   
   <div class="modal-content">
       
       <div class="modal-container">
          <div class="modal-header">
           <button type="button" class="close" data-dismiss="modal">×</button>
           <h4 class="modal-title">Delete Confirm Box</h4>
            </div>
       <div class="modal-body">
           <p> Are you sure you want to delete?</p>
       </div>
       <div class="modal-footer">
            <a class="btn btn-danger modal_delete_link" href="">Delete</a>
           <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
       </div>
    </div>
   </div>
   </div>
</div>Any help is very useful.
