JezK
Edit File: contactus_messages.php
<?php include('admin_functions.php'); if($_SESSION['username']=='') { echo "<script>location.replace('index.php');</script>" ; } $admin=new adm_functions(); $contacts = $admin->get_contact_messages(); $i=1; $reposrtdata =''; foreach($contacts as $k=>$v){ $contactdata .='<tr> <td>'.$i.'</td> <td>'.$v['name'].'</td> <td>'.$v['email'].'</td> <td>'.$v['message'].'</td> <td>'.$v['created_dt'].'</td> <td><a href="contactmessage_view.php?id='.$v['contactid'].'"><input type="button" class="btn btn-success" value="View"></a> <a href="contactus_messages.php?id='.$v['contactid'].'" onclick="return validme()"><input type="button" class="btn btn-danger" value="Delete"></a> </td> </tr>'; $i++; } if($_GET['id']!='') { $newsdata = $admin->contact_delete_message($_GET['id']); if($newsdata == "200"){ echo "<script>alert('Contact deleted successfully.');</script>" ; echo "<script>location.replace('contactus_messages.php');</script>" ; } } $currentPage='contactus_messages'; include"header.php" ?> <div class="main-panel"> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar bar1"></span> <span class="icon-bar bar2"></span> <span class="icon-bar bar3"></span> </button> <a class="navbar-brand" href="#">Contact Us Messages</a> </div> </div> <div class="collapse navbar-collapse"> </div> </nav> <div class="content"> <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <div class="content table-responsive table-full-width"> <table class="table table-striped" id="example"> <thead> <th>S.No</th> <th>UserName</th> <th>Email</th> <th>Message</th> <th>Contact Date & Time</th> <th>Action</th> </thead> <tbody> <?php echo $contactdata; ?> </tbody> </table> </div> </div> </div> </div> </div> <?php include"footer.php" ?> <script> $(document).ready(function() { $('#example').DataTable(); }) function validme() { var x=confirm("Are you sure to delete this message?"); if(x!='') return true; else return false; } </script> <link href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" rel="stylesheet"> <script src="//code.jquery.com/jquery-1.12.4.js"></script> <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>