...

View Full Version : limit reults



markman641
08-18-2011, 09: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, 09: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, 09:23 PM
http://dev.mysql.com/doc/refman/5.5/en/select.html



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):

markman641
08-18-2011, 09:24 PM
thanks!!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum