-1

This will probably too easy but I cant find the answer. I have a list made by a mysql query, but I want to only show like X results and then have some button to show the next 5 etc. How do I make that?

P.S: I guess it would be similar, but how do change the sort without making another query?

4

1 回答 1

0

例如您的查询是

    $add=5*(int)$_GET['page'];
    $first=$add;
    $second=$add+5;
    $query=mysql_query("SELECT * FROM 'tbl' LIMIT $first,$second");
    while($row=mysql_fetch_assoc()){
         echo $row['test'];
    }

因此,如果您想获得 5,10 之间的行,那么您必须同时添加 5,如果您发送此请求: localhost/index.php?page=2 那么您将有此查询;

    $query=mysql_query("SELECT * FROM 'tbl' LIMIT 10,15");

如果你想使用 top 那么它是这样的: SELECT TOP 10 FROM 'tblUser' ORDER BY topscore;

于 2013-06-20T13:51:53.267 回答