php - Expanding page navigation splitted Query result -


i have results of query getting split pages. done using following code:

    <?php      if (isset($_get["page"])) { $page  = $_get["page"]; } else { $page=1; };      $start_from = ($page-1) * 10;      $sql = "select * profiles hoofdrubriek = '".$rubriekpage2."'  order bedrijfsnaam limit $start_from, 10";      $rs_result = mysql_query($sql);  while ($row = mysql_fetch_assoc($rs_result)) {   echo result....  }  ?> 

next creating navigation seperate pages:

<?php  if(mysql_num_rows($rs_result)!=0){  ?>  <br /><div style="margin-left:200px;width:300px;text-align:center;background-color:">pagina's:<br clear="left">    <?php  $sql = "select count(bedrijfsnaam) profiles hoofdrubriek = '".$rubriekpage2."'";  $rs_result = mysql_query($sql);  $row = mysql_fetch_row($rs_result);  $total_records = $row[0];  $total_pages = ceil($total_records / 10);   if ($total_pages>10) $total_pages=10; ($i=1; $i<=$total_pages; $i++) {              echo "<a style=\"float:none;display:inline-block;color:white;width:22px;text-align:center;text-decoration:none;font-size:20px;background-color:#483435;margin-left:4px\" href='".$plaatsnaam7.".php?page=".$i."'>".$i."</a> ";   };  ?> 

all works great far, no problems there. however: limited 10 pages , that's it. of course can alter number 25, previous , next button beside 'numbers' navigation. if there more 10 pages, put next button on right display next 10 digits , on...

i've been googling evening, haven't come single decent result, tutorial or that. of guys in mood lend me hand? thanks!

check whether current page not first, if next 10 pages valid, , display previous, next, , page links if so.

 function page_link($i) {       echo "<a style=\"float:none;display:inline-block;color:white;width:22px;text-align:center;text-decoration:none;font-size:20px;background-color:#483435;margin-left:4px\" href='".$plaatsnaam7.".php?page=".$i."'>".$i."</a> ";    }    function page_next($i){        // link page $i arrow right   }   function page_prev($i){       // link page $i arrow left   }  $s = $_get['page'];  if ($s > 1) page_prev($s - 1);   ($i = $s; $i * 10 < $total_count && $i < $s + 10; $i++) {        page_link($i);  }  if (10 + $i * 10 < $total_count) page_next($i+1); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -