mysql - Pagination in while loop with php -


i'm newbee php,trying learn. i've search other topic while loop pagination not satisfied.

i have 70 user records in database,wants list them html table. i'm showing records code. how can make simple pagination these codes? please me.

<table class="table">     <thead>       <tr>         <th>id</th>         <th>name</th>         <th>surname</th>         <th>email</th>         <th>password</th>         <th>date</th>         <th>gender</th>       </tr>     </thead>     <tbody>      <?php     $q = "select * users order uid asc";     $r = mysqli_query($dbc,$q);      while($userlist = mysqli_fetch_assoc($r)){ ?>       <tr>           <td><?php echo $userlist['uid']; ?></td>           <td><?php echo $userlist['name']; ?></td>           <td><?php echo $userlist['surname']; ?></td>           <td><?php echo $userlist['email']; ?></td>           <td><?php echo $userlist['password']; ?></td>           <td><?php echo $userlist['date']; ?></td>           <td><?php echo $userlist['gender']; ?></td>       </tr>       <?php } ?>          </tbody>   </table> 

the follow provide simple pagination starting point. need supply formatting pagination , such.

<table class="table">     <thead>         <tr>             <th>id</th>             <th>name</th>             <th>surname</th>             <th>email</th>             <th>password</th>             <th>date</th>             <th>gender</th>         </tr>     </thead>     <tbody> <?php     $q = "select count(*) `numrows` `users` order `uid` asc";     $c = mysqli_query($dbc,$q);     if($c) {         if($t = mysqli_fetch_assoc($c)) {             $numrows = $t['numrows'];         }     }      $numrows = 0;     $rowsperpage = 10;     $currpage = isset($_request['currpageno']) && $_request['currpageno'] != 0 ? $_request['currpageno'] : 1;     $numpages = ceil($numrows / $rowsperpage);     $startrow = ($currpage - 1) * $rowsperpage;     if($startrow > $numrows) {         $startrow = $numrows - $rowsperpage;     }     if($startrow < 0) {         $startrow = 0;     }       $q = "select * `users` order `uid` asc limit ".$startrow.",".$rowsperpage.";";     $r = mysqli_query($dbc,$q);      while($userlist = mysqli_fetch_assoc($r)){  ?>         <tr>                 <td><?php echo $userlist['uid']; ?></td>                 <td><?php echo $userlist['name']; ?></td>                 <td><?php echo $userlist['surname']; ?></td>                 <td><?php echo $userlist['email']; ?></td>                 <td><?php echo $userlist['password']; ?></td>                 <td><?php echo $userlist['date']; ?></td>                 <td><?php echo $userlist['gender']; ?></td>         </tr>         <?php } ?>            </tbody> </table> <div id='pagination'> <?php     for($pgno = 1;$pgno <= $numpages;$pgno++) {         echo "<a class='' href='?currpageno=".$pgno."'>".$pgno."</a>";     } ?> </div> 

Comments