php - Pagination All from sql and Pagination of Alphabetical navigate -


i used pagination in php mysqli , alphabetical navigator in same page. working well. if click on alphabet like: b display 10 sql table's data b , when click page 2 display rest of data alphabet b, cannot display rest of data b display next 10 data of sql table's.

enter image description here

i have total 100 row in sql a=20, b=30, c=5, d=15 ... etc. used pagination display 10 data @ time , alphabetical navigator display data alphabet.

now want:

when user load page, pagination work data name asc limit 10, when user click on alphabet, pagination work alphabet.

here code:

<?php include_once('db.php');  //for pagination     $limit = 10;   if (isset($_get["page"])) { $page  = $_get["page"]; } else { $page=1; };   $start_from = ($page-1) * $limit;  //for alphabet $sort = isset($_get['firstletter']) ? filter_input(input_get,     'firstletter',filter_sanitize_url) : "" ;       if($sort == "") {     $sql = "select * evideo order name asc limit $start_from, $limit";     }else{     $sql = "select * evideo name '$sort%' order name asc     limit $start_from, $limit" ;     }     $execute = $dbh->query("$sql");        //display alphabet        echo '<div class="well abc-pag"><b>find alphabetically:</b> ';        ($i = 65; $i < 91; $i++) {        printf('<a href="%s?firstletter=%s">%s</a>  ', $_server['php_self'] , chr($i), chr($i));        }        printf('<a href="%s">all</a>', $_server['php_self'] );        echo "</div>";    $rowcount = $execute->num_rows ;     $c = 1; if ($rowcount > 0 ) { $row = $dbh->query($sql) ;  while ($row = $execute->fetch_assoc()) {  $name = $row['name']; $detail = $row['detail']; $link = $row['link']; $pic = $row['pic']; if (empty($pic)) $pic = "../images/edir.jpg";  echo '<article class="white-panel"><a href="'.$link.'">'; echo '<img src="images/loader.gif" border="0" data-echo="'.$pic.'"    class="emusicpro img-responsive"></a>'; echo '<div class="well"><strong>'.$name.'</strong><br>'.$detail.'</div>'; echo '</article>';       }     } else {echo '<p align="center"><b>no data found.</b></p>';}    //display pagination $sql = "select count(id) evideo";   $rs_result = mysqli_query($dbh,$sql);   $row = mysqli_fetch_row($rs_result);   $total_records = $row[0];   $total_pages = ceil($total_records / $limit);       $paglink = "<ul class='pagination'>";           ($i=1; $i<=$total_pages; $i++) {            $paglink .= "<li><a href='ebox2.php?page=".$i."'>".$i."</a></li>";           };       echo $paglink . "</ul>";   


Comments