求教一下个位高手,我做的网页添加 重复区域 显示50条信息 升序 不能用分页。新信息在页面底部旧信息在页面顶部,可是信息添加超过50条时页面显示的还是1-50条信息,我想在添加一条新信息的同时旧信息就不显示一条。谢谢
回复讨论(解决方案)
如果是在数据库里读取的话,先desc一下 然后limit取前五十条就好了啊
select * from table desc order by id limit 0,49
要是还想升序排列 可以select * from (select * from table order by id desc limit 0,49 ) order by id asc
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_R1 = 10;
$pageNum_R1 = 0;
if (isset($_GET['pageNum_R1'])) {
$pageNum_R1 = $_GET['pageNum_R1'];
}
$startRow_R1 = $pageNum_R1 * $maxRows_R1;
$maxRows_R1 = 35;
$pageNum_R1 = 0;
if (isset($_GET['pageNum_R1'])) {
$pageNum_R1 = $_GET['pageNum_R1'];}
$startRow_R1 = $pageNum_R1 * $maxRows_R1;
mysql_select_db($database_liandb, $liandb);
$query_R1 = "SELECT * FROM mydb1 ORDER BY id ASC";
$query_limit_R1 = sprintf("%s LIMIT %d, %d", $query_R1, $startRow_R1, $maxRows_R1);
$R1 = mysql_query($query_limit_R1, $liandb) or die(mysql_error());
$row_R1 = mysql_fetch_assoc($R1);
我应该怎么加进去哪?
$query_R1 = "SELECT * FROM mydb1 ORDER BY id desc";
$query_limit_R1=sprintf("%s LIMIT %d, %d", $query_R1, $startRow_R1, $maxRows_R1);
$query_limit_R1_Supper ="select * from (".$query_limit_R1.") order by id asc "
$R1 = mysql_query($query_limit_R1_Supper, $liandb) or die(mysql_error());
$row_R1 = mysql_fetch_assoc($R1);
$query_limit_R1引号可能是少加了。如果不好用你调试一下
$pageNum_R1 = $_GET['pageNum_R1'];}
$startRow_R1 = $pageNum_R1 * $maxRows_R1;
mysql_select_db($database_liandb, $liandb);
$query_R1 = "SELECT * FROM mydb1 ORDER BY id DESC";
$query_limit_R1 = sprintf("%s LIMIT %d, %d", $query_R1, $startRow_R1, $maxRows_R1);
$query_limit_R1_Supper ="select * from (".$query_limit_R1.") order by id asc ";
$R1 = mysql_query($query_limit_R1, $liandb) or die(mysql_error());
$row_R1 = mysql_fetch_assoc($R1);
这样是降序了,升序不起作用了。
错了。。。
$R1 = mysql_query($query_limit_R1_Supper, $liandb) or die(mysql_error());
里面不是$query_limit_R1
麻烦帮我详细的填一下呗,我这菜鸟、谢谢
$pageNum_R1 = $_GET['pageNum_R1'];}$startRow_R1 = $pageNum_R1 * $maxRows_R1;mysql_select_db($database_liandb, $liandb);$query_R1 = "SELECT * FROM mydb1 ORDER BY id desc";$query_limit_R1=sprintf("%s LIMIT %d, %d", $query_R1, $startRow_R1, $maxRows_R1);$query_limit_R1_Supper ="select * from (".$query_limit_R1.") order by id asc "$R1 = mysql_query($query_limit_R1_Supper, $liandb) or die(mysql_error());$row_R1 = mysql_fetch_assoc($R1);
$pageNum_R1 = $_GET['pageNum_R1'];}
$startRow_R1 = $pageNum_R1 * $maxRows_R1;
mysql_select_db($database_liandb, $liandb);
$query_R1 = "SELECT * FROM mydb1 ORDER BY id DESC";
$query_limit_R1 = sprintf("%s LIMIT %d, %d", $query_R1, $startRow_R1, $maxRows_R1);
$R1 = mysql_query($query_limit_R1_Supper, $liandb) or die(mysql_error());
$row_R1 = mysql_fetch_assoc($R1);
错误提示:查询是空的
$query_limit_R1 = sprintf("%s LIMIT %d, %d", $query_R1, $startRow_R1, $maxRows_R1);
$R1 = mysql_query($query_limit_R1_Supper, $liandb) or die(mysql_error());
这两行中间那行删除了?
$query_limit_R1=sprintf("%s LIMIT %d, %d", $query_R1, $startRow_R1, $maxRows_R1);
$query_limit_R1_Supper ="select * from (".$query_limit_R1.") order by id asc "
$R1 = mysql_query($query_limit_R1_Supper, $liandb) or die(mysql_error());
中间那行呢
$pageNum_R1 = $_GET['pageNum_R1'];}
$startRow_R1 = $pageNum_R1 * $maxRows_R1;
mysql_select_db($database_liandb, $liandb);
$query_R1 = "SELECT * FROM mydb1 ORDER BY id DESC";
$query_limit_R1 = sprintf("%s LIMIT %d, %d", $query_R1, $startRow_R1, $maxRows_R1);
$query_limit_R1_Supper ="select * from (".$query_limit_R1.") order by id asc ";
$R1 = mysql_query($query_limit_R1_Supper, $liandb) or die(mysql_error());
$row_R1 = mysql_fetch_assoc($R1);
错误提示:每一个派生表必须有自己的别名
$query_limit_R1_Supper ="select * from (".$query_limit_R1.") M, order by id asc ";
$query_limit_R1_Supper ="select M.* from (".$query_limit_R1.") M, order by id asc ";
还是一样的错误
有一个错误在您的SQL语法;检查手册,对应你的MySQL服务器版本为正确的语法使用附近的订单id asc在1号线
$query_limit_R1_Supper ="select M.* from (".$query_limit_R1.") M order by id asc ";
应该是多加了个逗号。。非常抱歉
这回好了,感谢你的耐心帮助,可是不知道怎么选精彩回答?
本文原创发布php中文网,转载请注明出处,感谢您的尊重!