开发者

How to display other values, when a query is limited by 3?

开发者 https://www.devze.com 2022-12-27 18:38 出处:网络
Can anyone tell me how to display the other values, when a query is limited my 3. In this question I asked how to order and limit values, but now I want to show the others in another query. How would

Can anyone tell me how to display the other values, when a query is limited my 3. In this question I asked how to order and limit values, but now I want to show the others in another query. How would I go about d开发者_开发知识库oing this?

Here's the code I used before:

$query  = "SELECT gmd FROM account ORDER BY gmd DESC LIMIT 3";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
}


If display all rows use like this :

$query  = "SELECT gmd FROM account ORDER BY gmd DESC";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
}

If display all rows without that 3 rows use like this :

$query  = "SELECT gmd FROM account ORDER BY gmd DESC LIMIT 3,1000000";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
}


if you LIMIT the resultset in the query you only get 3 rows returned.

if you want to show the rest, don't limit inside the query, but check the rowcount in your php loop


 SELECT gmd FROM account ORDER BY gmd DESC LIMIT 3,9999999999

or may be you need pagination


SELECT gmd FROM account ORDER BY gmd DESC LIMIT 3,10

Will skip first 3 values and display next 10 ones satisfying the condition. This is MySQL only solution though.

0

精彩评论

暂无评论...
验证码 换一张
取 消