如何订购此结果??
$range = 5; // you'll be selecting around this range.
$min = $rank - $range;
$max = $rank + $range;
$limit = 10; // max number of results you want.
$result = mysql_query("select * from table where rank between $min and $max limit $limit");
while($row = mysql_fetch_array($result))
{
echo $row['name']." - ".$row['rank']."<br>";
}
答案 0 :(得分:2)
$result = mysql_query(
"select * from table where rank between $min and $max " .
"order by rank asc limit $limit"
);
答案 1 :(得分:0)
使用“order by” - 子句:
mysql_query("select * from table where rank between $min and $max order by rank limit $limit");
这会将您的结果从小到大的顺序排序。
使用"order by rank desc"
以后代方向排序。 (大 - >小)