MySQL Forums
Forum List  »  Newbie

Re: break mysql query? Is this possible in my sql
Posted by: Rick James
Date: November 22, 2009 01:02PM

OK, more than 10 lines...
$pg = '';  $dir = 'ASC';  // if initial page (not Next/Prev)
$after = @$_GET['after'];
if (isset($after))
{
    if (! isnumber($after))
        die("Someone hacking!");
    $pg = "AND id > $after";
    $dir = 'ASC';
}
$before = @$_GET['before'];
//...

$sql = "SELECT ... WHERE ... $pg ORDER BY id $dir LIMIT 10";

echo "<a href=\"?after=$after\">Next Page</a>";
echo "<a href=\"?before=$before\">Prev Page</a>";
This will be fast, efficient, and will scale well.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.