添加重复区域后、升序、不用分页
回复讨论(解决方案)
如果是在数据库里读取的话,先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 ";
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$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 desc";
$query_limit_R1=sprintf("%s LIMIT %d, %d", $query_R1, $startRow_R1, $maxRows_R1);
$query_limit_R1_Supper ="select * from (".$query_limit_R1.") M, order by id asc ";
$R1 = mysql_query($query_limit_R1_Supper, $liandb) or die(mysql_error());
$row_R1 = mysql_fetch_assoc($R1);
if (isset($_GET['totalRows_R1'])) {
$totalRows_R1 = $_GET['totalRows_R1'];
} else {
$all_R1 = mysql_query($query_R1);
$totalRows_R1 = mysql_num_rows($all_R1);
}
$totalPages_R1 = ceil($totalRows_R1/$maxRows_R1)-1;
$queryString_R1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_R1") == false &&
stristr($param, "totalRows_R1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_R1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_R1 = sprintf("&totalRows_R1=%d%s", $totalRows_R1, $queryString_R1);
?>
有一个错误在您的SQL语法;检查手册,对应你的MySQL服务器版本为正确的语法使用附近的订单id asc在1号线
$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 ";
应该是多加了个逗号。。非常抱歉
这回好了,感谢你的耐心帮助,可是不知道怎么选精彩回答?