我正在使用php从mysql数据库加载数据。但是,我希望将加载限制在特定的行数(例如: 10行),并添加更多的load特性,以便使用Jquery获得更多的行。
提前谢谢你!
发布于 2014-05-13 17:23:44
限制MySQL中的查询:(这将返回前10行)
select * from table_name limit 10 然后,在javascript中,您可能需要计算查询db的次数,以便您的查询类似于:
select * from table_name limit 10,20
// 20,30 40,50 etc etc etc
// for example say you pass in a count variable, so this would be
// 3rd time you've queried
// $_POST = 3
$lower = ($_POST['count'] * 10) - 10;
$upper = $_POST['count'] * 10;
// would result in:
select * from table_name limit $lower, $upper // 20, 30但是,您也可以使用mysql的offset关键字
$offset = $_POST['count'] * 10;
select * from table_name limit 10 offset $offset它基本上是从db中获取下10行,每个查询都是从AJAX查询的。
https://stackoverflow.com/questions/23637305
复制相似问题