keep post variable in php pagination -


i have php pagination page post submit user search something, query mysql in first page ok, in next page, have white blank page.

below paging code.

$_session['nationality'] = $_post['nationality']; $reclimit = 2;  if(isset($_get['page'])){ $page = $_get['page']; } else { $page = 1; }  $start = (($page-1) * $reclimit);  $sql = "select userid, name, left(hkid, 4) hkid, description, nationality, photo_1, photo_2, photo_3 $tbl_name `nationality` '%$_session[nationality]%'"; $records = $con->query($sql);  $total = $records->num_rows; $tpages = ceil($total / $reclimit);  $rec = "select userid, name, left(hkid, 4) hkid, description, nationality, photo_1, photo_2, photo_3 $tbl_name `nationality` '%$_session[nationality]%' limit $start, $reclimit"; $records = $con->query($rec);  while ($row = mysqli_fetch_assoc($records)){  // loop record  }  // paging echo '<ul class="pagination pagination-lg">'; for( $i=1; $i <= $tpages; $i++ ) { $active = $i == $page ? 'class="active"' : ''; echo "<li $active ><a href='$_server[php_self]?page=" .$i. "'>" .$i. "</a></li>"; } echo '</ul>'; 

this works me:

<?php   $limit =3; if (!isset($_get['pg'])) {     $pg = 1; } else {     $pg = $_get['pg']; } $start = ($pg - 1 ) * $limit;                         $sql = "select * tablename limit $start , $limit"; ?> 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -