<script>
  function del(iden,action){
    var dataString = "id="+iden+"&action="+action;
    var status = $("#status").val();
    var identity = $('#loadings')+iden;
    var confirms = confirm("Are you sure you want to continue?");
    if (confirms == true) {
    $.ajax({
        type: "POST",
        url: "control.php",
        cache : false,
        data : dataString,
        beforeSend : function(){
            $('#del'+iden).hide();
            $('#loadings'+iden).show();
        },
        success : function(response){
            $('#loadings'+iden).hide();
            document.getElementById('inputHere').innerHTML = response;
            $('#myModal').modal('show');
            window.location.reload(1);
        }
    });
}
}
</script>
<div class="x_content">
    <table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
                            <thead>
                             <tr>
                                <th>S/N</th>
                                <th>Name</th>
                                <th>Action</th>
                              </tr>
                            </thead>
                            <tbody>
                        <?php
                         $select = $conn->query("SELECT * FROM notes WHERE package = '$vlink2'");
                            $fetch = $select->fetchAll(PDO::FETCH_OBJ);
                            $count = $select->rowCount();
                            $serial = 1;
                            if ($count > 0) {
                              foreach ($fetch as $value) {
                              $noteid = $value->id;
                              $title = $value->title;
                              $text = $value->text;
                            ?>
                              <tr>
                                <td><?php echo $serial; ?></td>
                                <td><?php echo $title; ?></td>
                                <td><button class="btn btn-default btn-xs" data-toggle="modal" data-target="#edit<?php echo $noteid ?>" title="View Content"><i class="fa fa-eye"></i></button>

                                <button class="btn btn-default btn-xs" title="Delete" id="del<?php echo $noteid?>" onclick= "del('<?php echo $noteid ?>', 'delnote')"><i class="fa fa-trash"></i></button><span id="loadings<?php echo $noteid ?>" style="display:none"><img src="img/loading.gif"></span>

                                </td>
                                <div class="modal fade" id="edit<?php echo $noteid ?>" role="dialog">
                                    <div class="modal-dialog modal-lg">
                                      <div class="modal-content">
                                        <div class="modal-header">
                                          <button type="button" class="close" data-dismiss="modal">&times;</button>
                                          <h4 class="modal-title">Viewing <?php echo "$title"; ?></h4>
                                        </div>
                                        <div class="modal-body">
                                        <p><?php echo "$text"; ?></p>
                                        </div>
                                        </div>
                                      </div>
                                    </div>
                              </tr>
                              
                            <?php
                            $serial++;
                              }
                            }
                        ?>
                            </tbody>
                          </table>                
</div>

                      


<div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog modal-sm">
      <div class="modal-content">
        <div class="modal-body text-center">
        <div id="inputHere">

        </div>
        </div>
        </div>
      </div>
    </div>


<div class="modal fade" id="myModal2" role="dialog">
    <div class="modal-dialog modal-sm">
      <div class="modal-content">
        <div class="modal-body text-center">
        <?php  
        if (isset($mess)) {
        echo "$mess";
        }
        ?>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Ok</button>
        </div>
        </div>
      </div>
    </div>

<?php
if(isset($mess)){
?>
<script type="text/javascript">
   $(window).load(function(){
   $('#myModal2').modal('show');
   }); 
</script>
<?php
  }
?>