JezK
Edit File: villages.php
<?php include "./app/admin_functions.php"; $connect=new admin(); $connect->dbconnection(); $alertScript=''; if(isset($_SESSION['new_village_status'])) { if($_SESSION['new_village_status'] == 'success') { $alertScript="<script>alert('New Village Added Successfully.')</script>"; unset($_SESSION['new_village_status']); } } else if(isset($_SESSION['village_update_status'])) { if($_SESSION['village_update_status'] == 'success') { $alertScript="<script>alert('Village Details Updated Successfully.')</script>"; unset($_SESSION['village_update_status']); } } echo $alertScript; $current_page='villages'; $current_heading='Villages'; include 'header.php'; ?> <div class='contain'> <!--<h1>Blood Donor</h1> <hr>--> <div class="view"> <div class='row pull-right bttn'> <a href='villages_add.php'><input type='button' class='btn btn-info ' value='ADD'></a> </div> <br><br> <div class="table-responsive"> <table class=" tbl table table-bordered data-table"> <thead> <tr> <th>S.No</th> <th>Mandals</th> <th>Villages</th> <th>Action</th> </tr> </thead> <tbody> <?php //$data=$connect->mandal_selection(); $villagedata=$connect->villagetable(); $count=1; $tableRowCount=0; foreach($villagedata as $vlgtabledata) { $tableRowCount++; echo '<tr><td>'.$count.'</td><td>'.$vlgtabledata['mandal_name'].'</td> <td>'.$vlgtabledata['village_name'].'</td><td><label class="glyphicon glyphicon-eye-open"></label> <a href="village_view.php?id='.$vlgtabledata['village_id'].'">Edit</a> '; if($connect->isVillageHasDonor($vlgtabledata['village_id']) == 2){ echo '<label class="glyphicon glyphicon-trash"></label> <a onclick="return confirmDelete()" href="village_delete.php?id='.$vlgtabledata['village_id'].'">Delete</a>'; echo '</td></tr>'; } $count++; } ?> </tbody> </table> </div> </div> </div> <hr> <?php if($tableRowCount > 0) { /* Run Data Table when Rows are more than One. */ echo '<script> $(document).ready(function(){ $(".data-table").DataTable({ "lengthMenu": [[10, 20, 50, 100], [10, 20, 50, "All"]] } ); }); </script>'; } include 'footer.php'; ?> <script type='text/javascript'> function confirmDelete() { return confirm("Are you sure you want to delete this village"); } </script>