View Full Version : limit reults

08-18-2011, 10:13 PM
hello, i have the following code:

$get_name = mysql_query("SELECT `id`, `name`, `link`, `value`, `description` from `offers` WHERE `countries` = 'us' LIMIT 25, 50");
while($namerow = mysql_fetch_array($get_name)) {
$id = $namerow["id"];
$link = $namerow["link"];
$name = $namerow["name"];
$amount = $namerow["value"];
$desc = $namerow["description"];

and it says limit 25,50 which is supposed to only results 25-50 but instead its showing up 50 results on the page? the page where its limited 0, 25 works fine. also on the pages where its 50,75 its showing some of the same results from the other pages

Old Pedant
08-18-2011, 10:21 PM
You have misread the documentation.

The syntax is

... LIMIT offset, rowcount

So if you always want 25 rows, always end your LIMIT with 25. All you change is the starting record number ("offset").

Old Pedant
08-18-2011, 10:23 PM

With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):

08-18-2011, 10:24 PM