gunmetal Posted October 16, 2010 Report Share Posted October 16, 2010 Cjau visiem. kāds zin labu php paginatoru (lappušu dalītāju) Ne pats māku to izveidot ne netā normālu atrast :( Lūdzu palīdziet Man vajag to paginatoru Quote Link to comment Share on other sites More sharing options...
snach15 Posted October 16, 2010 Report Share Posted October 16, 2010 http://php.lv/f/topic/2062-guestbook/ http://php.lv/f/topic/765-linki-uz-nakamam-lapam/ http://php.lv/f/topic/1330-kaa-sdaliit/ http://php.lv/f/topic/2881-lapu-daliitaajs/ http://php.lv/f/topic/2788-mysql-datu-sadaliishana-vairaakaas-lapaas/ http://php.lv/f/topic/16161-php-paginator-galerijai/page__p__126275__hl__paginator__fromsearch__1#entry126275 Quote Link to comment Share on other sites More sharing options...
Just_Learning Posted October 17, 2010 Report Share Posted October 17, 2010 <?php include('pagination.php'); if(isset($_GET['page']) and is_numeric($_GET['page'])){ $page = $_GET['page']; }else{ $page = 1; } $query = mysql_query("SELECT * FROM messages"); $total_users = mysql_num_rows($query); $per_page = 10; $offset = (($per_page * $page) - $per_page); $total_pages = ceil($total_users / $per_page); $pagination = pagination("ieraksti.php?page=", $page, $total_pages); $result = mysql_query("SELECT * FROM messages ORDER BY id DESC LIMIT ".$offset.", ".$per_page.""); $myrow = mysql_fetch_array($result); do{ echo "<a href='page.php?id=".$myrow['id']."'>".$myrow['name']."</a><br>"; } while($myrow = mysql_fetch_array($result)); echo "<p>".$pagination."</p>"; ?> šis ir kopēts ārā no manas lapas, skaties uzbūvi. fails kurš tiek inclūdots: <?php function pagination($link, $page, $total_pages) { $return = ""; // show first and previous links // disable if we're on the first page or if there's only 1 page if ($page != 1 && $total_pages > 1) { $return .= "<a href=\"".$link."1\">« Pirmā lapa </a> "; $return .= "<a href=\"".$link.($page - 1)."\">< Iepriekšējā lapa </a> "; } else { $return .= "<< Pirmā lapa "; $return .= "< Iepriekšējā lapa "; } // don't bother looping if there's only 1 page if ($total_pages == 1) { $return .= "1"; } else { // placeholders so we know if we've already shown dots already or not $dots_before = 0; $dots_after = 0; // loop through all the pages starting at 1 for ($i = 1; $i <= $total_pages; $i++) { // are we at the current page? if ($i == $page) { if ($i == 1) { // if this is page 1, don't put in a comma before the number $return .= $i; } else { // not the first page, put in a comma $return .= ", ".$i; } } else { // not at the current page, lets display links if (($i <= 2) || ($i < $page && $i >= ($page - 2)) || ($i > $page && $i <= ($page + 2)) || ($i > ($total_pages - 2))) { if ($i == 1) { // if this is page 1, don't put in a comma before the number $return .= "<a href=\"".$link.$i."\">".$i."</a>"; } else { // not the first page, put in a comma $return .= ", <a href=\"".$link.$i."\">".$i."</a>"; } } else { if ($i < $page) { // dots before the current page if ($dots_before == 0) { $dots_before = 1; $return .= ", ..."; } } else if ($i > $page) { // dots after the current page if ($dots_after == 0) { $dots_after = 1; $return .= ", ..."; } } } } } } // show next and last links // disable if we're on the last page or if there's only 1 page if ($page != $total_pages && $total_pages > 1) { $return .= " <a href=\"".$link.($page + 1)."\"> Nākamā lapa ></a>"; $return .= " <a href=\"".$link.$total_pages."\"> Pēdējā lapa »</a>"; } else { $return .= " Nākamā lapa >"; $return .= " Pēdējā lapa >>"; } return $return; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.