呃,我有过滤器的问题,我为价格范围创建过滤器,但是我需要将该数据排序为asc或desc?
我怎么能把那个东西搞砸了?
这是我的价格范围代码。
if(isset($_POST['sort'])) {
$cena_no = mysql_real_escape_string(trim($_POST['fl_cena_no']));
$cena_lidz = mysql_real_escape_string(trim($_POST['fl_cena_lidz']));
if(empty($cena_lidz)){
$cena_lidz = '99999999999999999999999999999999';
}
if(empty($cena_no)){
$cena_no = '0';
}
$_SESSION['sort'] = $_POST;
$per_page = $default;
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
$rows = mysql_query("SELECT * FROM zirglietas_pardod WHERE cena BETWEEN $cena_no AND $cena_lidz");
$pages = mysql_num_rows($rows);
$pages = ceil($pages / $per_page);
$querystring = "";
foreach ($_GET as $key => $value) {
if ($key != "page") $querystring .= "$key=$value&";
}
$result = mysqli_query($con,"SELECT * FROM zirglietas_pardod WHERE cena BETWEEN $cena_no AND $cena_lidz LIMIT " . (($page - 1) * $per_page) . ", ".$per_page."");
echo '<script>window.location.href = "pardod.php?page=1";</script>';
}
会话代码
if(isset($_SESSION['sort'])) {
$cena_no = $_SESSION['sort']['fl_cena_no'];
$cena_lidz = $_SESSION['sort']['fl_cena_lidz'];
if(empty($cena_lidz)){
$cena_lidz = '99999999999999999999999999999999';
}
if(empty($cena_no)){
$cena_no = '0';
}
$per_page = $default;
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
$rows = mysql_query("SELECT * FROM zirglietas_pardod WHERE cena BETWEEN $cena_no AND $cena_lidz");
$pages = mysql_num_rows($rows);
$pages = ceil($pages / $per_page);
$querystring = "";
foreach ($_GET as $key => $value) {
if ($key != "page") $querystring .= "$key=$value&";
}
$result = mysqli_query($con,"SELECT * FROM zirglietas_pardod WHERE cena BETWEEN $cena_no AND $cena_lidz LIMIT " . (($page - 1) * $per_page) . ", ".$per_page."");
}
当我发布价格范围后,我需要订购数据asc或desc,我创建了用于排序asc或desc的表单,但我无法更改会话数据。
这用于排序数据,但是当我启动价格范围会话时它不起作用。 会话开始,但没有改变。
if(isset($_POST['cena_asc'])) {
$cena_asc = mysql_real_escape_string($_POST['input_asc']);
$_SESSION['cena_asc'] = $_POST;
$result = mysqli_query($con,"SELECT * FROM zirglietas_pardod ORDER BY cena $cena_asc LIMIT " . (($page - 1) * $per_page) . ", ".$per_page."");
echo '<script>window.location.href = "?page=1";</script>';
}
if(isset($_SESSION['cena_asc'])) {
$cena_asc = $_SESSION['cena_asc']['input_asc'];
$result = mysqli_query($con,"SELECT * FROM zirglietas_pardod ORDER BY cena $cena_asc LIMIT " . (($page - 1) * $per_page) . ", ".$per_page."");
}