Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I were helped by one of the programmers with my above script. So here is a worked example of the reversed page navigation on PHP.</p> <pre><code>&lt;? $onpage = 10; // on page /* $pagerecord - display records per page $activepage - current page $records - total records $rad - display links near current page (2 left + 2 right + current page = total 5) */ function navigation($pagerecord, $activepage){ $records = 126; $rad = 4; if($records&lt;=$pagerecord) return; $imax = (int)($records/$pagerecord); if ($records%$pagerecord&gt;0)$imax=$imax+1; if($activepage == ''){ $for_start=$imax; $activepage = $imax-1; } $next = $activepage - 1; if ($next&lt;0){$next=0;} $end =0; $prev = $activepage + 1; if ($prev&gt;=$imax){$prev=$imax-1;} $start= $imax; if($activepage &gt;= 0){ $for_start = $activepage + $rad + 1; if($for_start&lt;$rad*2+1)$for_start = $rad*2+1; if($for_start&gt;=$imax){ $for_start=$imax; } } $meter = $rad*2+1; //$rad; --------------------- $new_meter = $for_start-1; if($activepage &lt; $imax-1){ $str .= ' &lt;a href="?page='.($start-1).'&amp;page_id='.$end.'"&gt;&lt;&lt;&lt; End&lt;/a&gt; &lt;span style="color:#CCCCCC"&gt;•&lt;/span&gt; &lt;a href="?page='.$prev.'&amp;page_id='.($imax-$prev-1).'"&gt;&lt; Forward&lt;/a&gt; | '; } for($i=$for_start-1; $i&gt;-1; $i--){ $meter--; //$new_meter++; //$line = '|'; if ($meter=='0'){ $line = ''; } $line = ''; if ($i&gt;0)$line = '|'; if($i&lt;&gt;$activepage){ $str .= " &lt;a href='?page=".$i."&amp;page_id=".($imax-$i-1)."'&gt;".($i)."&lt;/a&gt; ".$line." "; } else { $str .= " &lt;strong&gt;[".($i)."]&lt;/strong&gt; ".$line." "; } if($meter=='0'){ break; } } if($activepage &gt; 0){ $str .= " | &lt;a href='?page=".$next."&amp;page_id=".($imax-$next-1)."'&gt;Back &gt;&lt;/a&gt; &lt;span style='color:#CCCCCC'&gt;•&lt;/span&gt; &lt;a href='?page=".($end)."&amp;page_id=".($start-1)."'&gt;Start &gt;&gt;&gt;&lt;/a&gt; "; } return $str; } if(is_numeric($_GET["page"])) $page = $_GET["page"]; $navigation = navigation($onpage, $page); // detect navigation echo $navigation; ?&gt; </code></pre> <p><strong>$page</strong> = keeps the page number from the reversed order</p> <p><strong>$page_id</strong> = keeps the real page by serial order. so you can make SELECT queries to database and ORDER BY id DESC use.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload