master8080 Posted March 21, 2007 Share Posted March 21, 2007 Hi, i am busy with a image gallery and i have it working. but now i want to change my navigation menu this one: [1] [2] [3] [4] to: <<first [1] [2] [3] [4] [5] [6] last>> i have also this code, (c second code ) but i cant link it to my foto folder and unsort it from 10 to 1 ,like the newest u c first. i also numbered the pictures. can anyone help me, i searched for days. thnx <? $page = isset($_GET['page']) ? $_GET['page'] : 1; $a = '4'; //aantal plaatjes op 1 pagina $locatie = 'foto/'; //map van afbeeldingen //$width = '247'; //breedte van de plaatjes $PAGE_LIMIT = 2; //limiet per pagina //hieronder hoeft niks veranderd te worden if (!isset($_GET['pagina'])) { $pagina = 1; } else { $pagina = $_GET['pagina']; } $dir = opendir($locatie); $nr = '1'; // Haal de gegevens uit dir while (false !== ($file = readdir($dir))) { if (($file !== ".") and ($file !== "..")) { list($filename, $ext) = explode(".", $file); list($main, $sub, $include) = explode("/", $PHP_SELF); $files[$nr] = $file; $nr++; } } // tel de images op in de directory $a0 = count($files); /*tel de images op in de directory en deel ze door $a.($a= hoeveel images per pagina.)*/ $a1 = ($a0/$a); //voor het afronden naar een hele nummer $a2 = round($a1); // als de images per pagina groter zijn dan afgerond getal, blijf doortellen. if ($a1 > $a2) { $a2++; } $k = '1'; //terwijl $i ongelijk is aan $2 while ($k != ($a2 + 1)) { if ($pagina == $k) { //aantal plaatjes per pagina $j = (($a * $k)-$a); //afbeelding+nummer $afb = ($j + 1); while ($j != ($a * $k)) { // als afb. groter is dan alle images in directory if ($afb > $a0) { //nummer is $a x 1 $j = ($a * $k); } else { //laat plaatje zien echo "<img src=\"$locatie/$files[$afb]\"b order=O>"; //echo "<a href=\"$locatie/$files[$afb]\"><img src=\"$locatie/$files[$afb]\"b order=O></a> "; $afb++; $j++; } } //pagina nummers met links. dit werkt wel. $pagnr = '1'; echo "<br><br>"; //terwijl pagnr ongelijk is aan $2 while ($pagnr != ($a2 + 1)){ //als pagnanr pagina is. if ($pagnr == $pagina){ //laat pagina nummer zien dat niet klikbaar is echo "<b>[$pagnr]</b> "; } else { //alle andere pagina nummers zijn klikbaar echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?pagina=$pagnr\">[$pagnr]</a> "; } $pagnr++; } } $k++; } #--------------------> The extra navigation that do not link to the foto folder and read it-----------------------------------> echo 'Pagina '.$page.' <i><small>(totaal pagina´s: '.$a0.')</small></i><br><br>'; function show_pagenumbers($start, $end, $page, $a0, $PAGE_LIMIT) { $str = ''; for ($i = $start; $i <= $end; $i++) { if ($page == $i) { $str .= ' <b>[ '.$i.' ]</b> '; } else{ $str .= ' <a href="'.$_SERVER['PHP_SELF'].'?page='.$i.'&perpage='.$PAGE_LIMIT.'" title="Go to page '.$i.'">'.$i.'</a> '; } } return $str; } if ($a0 >= 1) { if($a0 > 5) { $start = $page - 4; $end = $page + 4; while($start < 1) { $start++; $end++; } while($end > $a0) { $start--; $end--; } //als page==1 true:false echo ( $page == 1 ) ? '<span style="color:#ccc;">« Eerste</span> ' : '<a href="'.$_SERVER['PHP_SELF'].'?page=1" title="Go to page 1">« Eerste</a> '; //$page > 4 true:false echo ( $page > 4 ) ? '...' : ''; echo show_pagenumbers($start, $end, $page, $a0, $PAGE_LIMIT); echo ( $page < $a0 - 3 ) ? '... ' : ' '; echo ( $page == $a0 ) ? ' <span style="color:#ccc;">Laatste »</span> ' : ' <a href="'.$_SERVER['PHP_SELF'].'?page='.$a0.'" title="Go to page '.$a0.'">Laatste »</a>'; } else { echo show_pagenumbers(1, $a0, $page, $a0, $PAGE_LIMIT); } } else { echo 'no page numbers yet'; } ?> beneath the original code that i found on the internet and that i also want to use to display images: Example code beneath:<<first [1] [2] [3] [4] [5] [6] [7]... Last>>. <?php $page = isset($_GET['page']) ? $_GET['page'] : 1; $totalPages = 666; $PAGE_LIMIT = 20; echo 'Pagina '.$page.' <i><small>(totaal pagina´s: '.$totalPages.')</small></i><br><br>'; function show_pagenumbers($start, $end, $page, $totalPages, $PAGE_LIMIT) { $str = ''; for ($i = $start; $i <= $end; $i++) { if ($page == $i) { $str .= ' <b>[ '.$i.' ]</b> '; } else{ $str .= ' <a href="'.$_SERVER['PHP_SELF'].'?page='.$i.'&perpage='.$PAGE_LIMIT.'" title="Go to page '.$i.'">'.$i.'</a> '; } } return $str; } if ($totalPages >= 1) { if($totalPages > 5) { $start = $page - 4; $end = $page + 4; while($start < 1) { $start++; $end++; } while($end > $totalPages) { $start--; $end--; } echo ( $page == 1 ) ? '<span style="color:#ccc;">« Eerste</span> ' : '<a href="'.$_SERVER['PHP_SELF'].'?page=1" title="Go to page 1">« Eerste</a> '; echo ( $page > 4 ) ? '...' : ''; echo show_pagenumbers($start, $end, $page, $totalPages, $PAGE_LIMIT); echo ( $page < $totalPages - 3 ) ? '... ' : ' '; echo ( $page == $totalPages ) ? ' <span style="color:#ccc;">Laatste »</span> ' : ' <a href="'.$_SERVER['PHP_SELF'].'?page='.$totalPages.'" title="Go to page '.$totalPages.'">Laatste »</a>'; } else { echo show_pagenumbers(1, $totalPages, $page, $totalPages, $PAGE_LIMIT); } } else { echo 'no page numbers yet'; } ?> Link to comment https://forums.phpfreaks.com/topic/43684-problem-with-page-numbering/ Share on other sites More sharing options...
master8080 Posted March 23, 2007 Author Share Posted March 23, 2007 Sorry i founded the solution. Link to comment https://forums.phpfreaks.com/topic/43684-problem-with-page-numbering/#findComment-213392 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.