javascript - Pagination button in php won't work -


i have form. when click paginate button, nothing. how can solve problem?

index.php:

<?php include('phpcode.php');   $record_per_page = 5;  $page_query = "select * student order id desc"; $page_result = mysqli_query($db, $page_query); $total_records = mysqli_num_rows($page_result); $total_pages = ceil($total_records/$record_per_page);  ?>  <?php  if (isset($_get['edit'])) {     $id = $_get['edit'];     $edit_state = true;      $rec = mysqli_query($db, "select * student id=$id");      if (count($rec) == 1 ) {         $record = mysqli_fetch_array($rec);         $name = $record['name'];         $course = $record['course'];         $age = $record['age'];         $department = $record['department'];         $dateadded = $record['dateadded'];         $id = $record['id'];     } } ?>  <!doctype html>  <html>  <head> <meta name ="viewport" content="width=device-width, initial-scale=1.0" /> <title>home</title>  <script src="js/jquery-1.11.3-jquery.min.js"></script>  <script type="text/javascript" src="js/jquery.bootpag.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#result").load("index.php");  //initial page number load $(".paging_link").bootpag({    total:<?php echo $total_pages; ?> }).on("page", function(e, num){     e.preventdefault();     $("#result").load("index.php", {'page':num}); });  }); </script>  <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />  <link href="css/style.css" rel="stylesheet" type="text/css"> </head>  <body>  <center><img src="hnu.png"></center>  <center><h1>hnu enrollment application</h1></center><br>  <?php if (isset($_session['message'])): ?>  <div class="msg">      <?php          echo $_session['message'];         unset($_session['message']);      ?> </div>  <?php endif ?>  <table> <thead>     <tr>         <th>id</th>         <th>name</th>         <th>course</th>         <th>age</th>         <th>department</th>         <th>date enrolled</th>          <th colspan="5">action</th>     </tr> </thead>  <?php  $record_per_page = 5;  if(isset($_post["page"]))     {         $page = filter_var($_post["page"], filter_sanitize_number_int, filter_flag_strip_high);         if(!is_numeric($page)){die('invalid page number!');}     } else     {         $page = 1;     }  $start_from = (($page-1)*$record_per_page);  $query = "select * student order id desc limit $start_from,  $record_per_page"; $result = mysqli_query($db, $query);   while ($row = mysqli_fetch_assoc($result)){?>      <tr>         <td><?php echo $row['id']; ?></td>         <td><?php echo $row['name']; ?></td>         <td><?php echo $row['age']; ?></td>         <td><?php echo $row['course']; ?></td>         <td><?php echo $row['department']; ?></td>         <td><?php echo $row['dateadded']; ?></td>         <td>              <a href="index.php?edit=<?php echo $row['id']; ?>" class="edit_btn">edit</a>          </td>          <td>              <a href="phpcode.php?del=<?php echo $row['id']; ?>" class="del_btn">delete</a>         </td>         </tr>          <?php } ?>     </table>  <div class="panel-footer text-center">         <div class="paging_link"></div>         </div>  <form method="post" action="phpcode.php">  <input type="hidden" name="id" value="<?php echo $id; ?>">      <div class="input-group">          <label>name</label>         <input type="text" name="name" required value="<?php echo $name; ?>">      </div>      <div class="input-group">          <label>course</label>         <input type="text" name="course" required value="<?php echo $course; ?>">      </div>      <div class="input-group">          <label>age</label>         <input type="text" name="age" required value="<?php echo $age; ?>">      </div>      <div class="input-group">          <label>department</label>         <input type="text" name="department" required value="<?php echo $department; ?>">      </div>      <div class="input-group">          <label>date enrolled</label>         <input type="date" name="dateadded" required value="<?php echo $dateadded; ?>">      </div>      <div class="input-group">          <?php if ($edit_state == false): ?>          <button type="submit" class="btn" name="add">add</button>      <?php else: ?>         <button type="submit" class="btn" name="update">update</button>      <?php endif ?>      </div>  </form>  </body>  </html> 

the phpcode.php:

<?php  session_start();  $db = mysqli_connect('localhost', 'root', '', 'crud', '3306');  $name = ""; $course = ""; $age = ""; $department = ""; $dateadded = ""; $id = 0; $edit_state = false;   if (isset($_post['add'])){      $name = $_post['name'];     $course = $_post['course'];     $age = $_post['age'];     $department = $_post['department'];     $dateadded = $_post['dateadded'];      mysqli_query($db, "insert student (name, course, age, department, dateadded) values ('$name', '$course', '$age', '$department', '$dateadded')");      $_session['message'] = "successfully added!";     header('location: index.php'); }  if (isset($_post['update'])){     $name = mysql_real_escape_string($_post['name']);     $course = mysql_real_escape_string($_post['course']);     $age = mysql_real_escape_string($_post['age']);     $department = mysql_real_escape_string($_post['department']);     $dateadded = mysql_real_escape_string($_post['dateadded']);     $id = mysql_real_escape_string($_post['id']);      mysqli_query($db, "update student set name='$name', course='$course', age='$age', department='$department', dateadded='$dateadded' id=$id");     $_session['message'] = "updated!";     header('location: index.php'); }  $result = mysqli_query($db, "select * student");  if (isset($_get['del'])){     $id = $_get['del'];      mysqli_query($db, "delete student id=$id");     $_session['message'] = "deleted!";     header('location: index.php'); }  ?> 

the css index.php:

    body{     font-size: 19px; }  table{     width: 60%;     margin: 30px auto;     border-collapse: collapse;     text-align: left; }  tr{     border-bottom: 1px solid #cbcbcb; }  th, td{     border: none;     height: 30px;     padding: 2px; }  tr:hover {     background: #f5f5f5; }  form{     width: 30%;     margin: 50px auto;     text-align: left;     padding: 20px;     border: 10px solid #bbbbbb;     border-radius: 5px; }  .input-group{     margin: 10px 0px 10px 0px; }  .input-group label{     display: block;     text-align: left;     margin: 3px; }  .input-group input{     height: 30px;     width: 150%;     padding: 5px 10px;     font-size: 16px;     border-radius: 5px;     border: 1px solid gray; }  .btn{     padding: 10px;     font-size: 15px;     color: white;     background: #5f9ea0;     border: none;     border-radius: 5px; }  .edit_btn{     text-decoration: none;     padding: 2px 5px;     background: #2e8b57;     color: white;     border-radius: 3px; }  .del_btn{     text-decoration: none;     padding: 2px 5px;     background: #800000;     color: white;     border-radius: 3px; }  .msg{     margin: 30px auto;     padding: 10px;     border-radius: 5px;     color: #3c763d;     background: #dff0d8;     border: 1px solid #3c763d;     width: 50%;     text-align: center; }  #result{     font-size:14px;     font-family:verdana, geneva, sans-serif;     width: 600px;     margin-left: auto;     margin-right: auto;     margin-top:80px; }  .paging_link {     padding: 0px;     margin: 0px;     height: 50px;     display: inline-block;     text-align: center; } .paging_link li {     display: inline-block;     list-style: none;     padding: 0px;     margin-right: 1px;     width: 40px;     text-align: center;     background: #47e556;     background: #47e556;     line-height: 25px; } .paging_link .disabled {     display: inline-block;     list-style: none;     padding: 0px;     margin-right: 1px;     width: 30px;     text-align: center;     line-height: 25px;     background-color: #666666;     cursor:inherit;  } .paging_link li a{     color:#ffffff;     text-decoration:none; } .page_result{     padding: 0px; } .page_result li{     //background: #e4e4e4;     background:#fff;     border-bottom:solid #00a2d1 1px;     margin-bottom: 5px;     padding: 10px;     list-style: none; } .page_result .page_name {     font-size: 14px;     font-weight: bold;     margin-right: 5px; } #link {     text-align:center; } 

it show 5 records per page , below records, there pagination button navigating on next record. after click on won't , won't show on next page, remain on first 5 records. don't know problem is, can solve problem guys?

the output


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -