On Friday 08 March 2002 10:12, CrossWalkCentral wrote: > I am interested in receiving some help on this one as well. > > "Will" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > Does anyone know how to limit a long record, like a news article that has > > 5 > > > > pages? > > > I want to limit it so it displays the first page then at the bottom it > > > prints: > > > > > > <<1 2 3 4 5 6 7>> > > > > > > then when you click 2 or the right arrow it displays the second page of > > > the record?
The following code assumes/requires: $result : an array containing the results from a query the number of items in the array is the number of rows returned from the query. $frm[batchpos] : a value that is passed from page to page containing the position at which to begin displaying the current page $frm[batchsize] : a predefined variable to control how many records are displayed per page #------------------------------------------------ if ($result) { ## Extract only the relevant batch of results to display ## ($frm[batchpos] -> $frm[batchpos]+$frm[batchsize]) ## Display the results navigation bar $RESULT_COUNT = count($result); $result = array_slice($result, $frm['batchpos'], $frm['batchsize']); $BATCHES = ($RESULT_COUNT / $frm['batchsize']); $RESULT_LINK = "Results: "; for ($i = 0; $i < $BATCHES; $i++) { $disp_start = ($i * $frm['batchsize']) + 1; $disp_end = $disp_start + $frm['batchsize'] - 1; if ($disp_end > $RESULT_COUNT) { $disp_end = $RESULT_COUNT; } $link_batchpos = $i * $frm['batchsize']; if ($disp_start != $disp_end) { $link = "[$disp_start - $disp_end] "; } else { $link = "[$disp_start]"; } if ($frm['batchpos'] != $link_batchpos) { $link = "<a href='$PHP_SELF?". rawurlencode("frm[category]")."=".rawurlencode($frm['category'])."&". rawurlencode("frm[batchpos]")."=".rawurlencode($link_batchpos)."'>". $link."</a>"; } $RESULT_LINK .= $link; } } echo $RESULT_LINK; #------------------------------------------------ The above is for reference only. Obviously you would need to change things to suit your situation and needs. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* Love is like the measles; we all have to go through it. -- Jerome K. Jerome */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php