Date: 03/19/05 (PHP Community) Keywords: mysql, sql Anyone know of any good pagaination functions - I've tried to code my own and I seem to be going around in cicles. What I've writen is:- ";
}
}
function disp_row($row)
{
// This function is to be edited to display the data how needed
echo"$lta href=\"?disp_t=topic&topic_id={$row[0]}\">".$row[2]."$lt/a>$ltbr>";
}
function disp_prev($offset, $base_url, $max_rows)
{
$tmp_offset=($offset-$max_rows);
if($tmp_offset $lt 0)
{
$tmp_offset = 0;
}
$offset=$tmp_offset;
$url=$base_url."&offset=".$offset;
echo"$lta href=".$url.">PREV$lt/a> ";
}
function disp_next($offset, $base_url, $total_rows, $max_rows)
{
$tmp_offset=($offset + $max_rows);
// echo"$ltp>tmp_offset=$tmp_offset ";
if($tmp_offset > $total_rows)
{
// Nothing Happening Here
}
else
{
$offset=$tmp_offset;
$url=$base_url."&offset=".$offset;
echo"$lta href=".$url.">NEXT$lt/a>$ltp>";
}
}
function disp_page_nums($offset, $base_url, $total_pages, $max_rows)
{
$page=(($max_rows/$offset)+1);
for($i=1;$i<$total_pages;$i+1)
{
if($i==$page)
{
echo "$ltfont size=\"-1\">[".$i."] $lt/font>";
}
else
{
$tmp_offset=($i * $max_rows);
$offset=$tmp_offset;
$url=$base_url."&offset=".$offset;
echo"<a href=".$url.">PREV</a>";
}
}
}
Source: http://www.livejournal.com/community/php/275374.html
|