The main part of code i m using for Forward and Backward is,
 
 
 
if($page > 1)
{
    $prev = ($page - 1);
    echo "<a 
href=\"".$_SERVER['PHP_SELF']."?page=$prev&&searchfor=$searchfor&&seek=$seek&&age1=$age1&&age2=$age2&&state=$state&&country=$country\"
 TARGET=\"_parent\"><<Previous</a>&nbsp;";
}
for($i = 1; $i <= $total_pages; $i++)
{
    if(($page) == $i)
    {
        echo "$i&nbsp;";
    } else
    {
            echo "<a 
href=\"".$_SERVER['PHP_SELF']."?page=$i&&searchfor=$searchfor&&seek=$seek&&age1=$age1&&age2=$age2&&state=$state&&country=$country\"
 TARGET=\"_parent\">$i</a>&nbsp;";
    }
}
// Build Next Link
if($page < $total_pages)
{
    $next = ($page + 1);
    echo "<a 
href=\"".$_SERVER['PHP_SELF']."?page=$next&&searchfor=$searchfor&&seek=$seek&&age1=$age1&&age2=$age2&&state=$state&&country=$country\"
 TARGET=\"_parent\">Next>></a>";
}

 
Change variables accroding to u.
 
 
 
John Taylor-Johnston <[EMAIL PROTECTED]> wrote:
Finally something I can give back, made by my little lonesome with no help :)

> I have a query that returns lots of rows so I want to display the results in blocks 
> of 25 or so on my web page and have forward and back buttons to navigate the results.

include it first:

include("settings_limit.inc");

then set $offset and $limit in your sql

$sql = 'SELECT *,MATCH (field1,field2)
AGAINST (\''.$searchenquiry.'\' IN BOOLEAN MODE)
AS relevancy FROM '.$table.'
WHERE MATCH (field1,field2)
AGAINST (\''.$searchenquiry.'\' IN BOOLEAN MODE)
ORDER BY relevancy DESC
LIMIT '.$offset.','.$limit.';';

------settings_limit.inc--------

#####################################################
## $mycounter is set by script calling settings_limit.inc ####
#####################################################

#####################################################
############### Set $offset & $limit ################
#####################################################

if((!$offset) || ($offset < 0))
{
$offset = 0;
}
$limit = 25;

#####################################################
############### $nextinsert #########################
#####################################################
$new_offset = $offset + $limit;
$disp = $limit;
if ($new_offset + $limit > $mycounter)
{
$disp = $mycounter - $new_offset;
}
if ($disp > 0)
{
$nextinsert = "Next ".$disp." Requests  [input] >\"> [input]  [input]  [input] ";
if($searchenquiry)
$nextinsert .= " [input] ";
if($scholarsenquiry)
$nextinsert .= " [input] ";
if($titlesenquiry)
$nextinsert .= " [input] ";
$nextinsert .= "";
}
#####################################################
############### $previousinsert #####################
#####################################################

$new_offset2 = $offset - $limit;
if ($offset > 0) // can display previous msg
{
$disp = $limit;
$previousinsert = " << Previous ".$disp." Requests";

$previousinsert = " [input]  Previous ".$disp." Requests [input]  [input]  [input] ";
if($searchenquiry)
$previousinsert .= " [input] ";
if($scholarsenquiry)
$previousinsert .= " [input] ";
if($titlesenquiry)
$previousinsert .= " [input] ";
$previousinsert .= "";
}
#####################################################
############### $lastinsert #########################
#####################################################

$new_offset3 = $mycounter - $limit;

if (($new_offset3 > $limit) and ($offset != $mycounter - $limit)) // can display goto 
end msg
{
$lastinsert = "Go To End  [input] >|\"> [input]  [input]  [input] ";
if($searchenquiry)
$lastinsert .= " [input] ";
if($scholarsenquiry)
$lastinsert .= " [input] ";
if($titlesenquiry)
$lastinsert .= " [input] ";
$lastinsert .= "";
}
#####################################################
############### $firstinsert ########################
#####################################################

$new_offset4 = $mycounter - $limit;
if ($new_offset4 > $limit) // can display goto beginning msg
{
$new_offset4 = 0;
$firstinsert = " [input]  Go To Beginning [input]  [input]  [input] ";
if($searchenquiry)
$firstinsert .= " [input] ";
if($scholarsenquiry)
$firstinsert .= " [input] ";
if($titlesenquiry)
$firstinsert .= " [input] ";
$firstinsert .= "";
}


#####################################################
############### Display Inserts #####################
#####################################################

#####################################################
if (($previousinsert) or ($nextinsert))
#echo "";
echo "";

#if (($previousinsert) || ($nextinsert))
#echo "(Sorted by id - $mycounter records found total)";

if (($previousinsert) or ($nextinsert))
echo "";

if (($firstinsert) and ($offset != 0)) echo "$firstinsert";

if ($previousinsert) echo "$previousinsert";

if (($previousinsert) && ($nextinsert)) echo "| ";

if ($nextinsert) echo "$nextinsert";

if ($lastinsert) echo "$lastinsert";

if (($previousinsert) or ($nextinsert))
#echo "";
echo "";

?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

 
                
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

Reply via email to