简体   繁体   English

PHP筛选并按最小数量排序

[英]PHP filter and sort by min amount

I've created a display package page with php and mysql. 我用php和mysql创建了一个显示包页面。 There're 10 buttons on top of the table to refilter the output. 表格顶部有10个按钮可对输出进行重新过滤。 How I did the refilter is by using $_GET['command'] which is equal to ' AND lock_in_period = '1yr' . 我如何进行重新过滤是通过使用$_GET['command']等于' AND lock_in_period = '1yr' I've tried to save $_GET['command'] under session, but it doesn't work. 我尝试将$_GET['command']保存在会话下,但不起作用。 The problem now is I can't get the min loan amount to sort asc or desc after I refilter the output. 现在的问题是在重新过滤输出后,我无法获得最小贷款额对asc或desc进行排序。

output 输出

在此处输入图片说明

mysql query: mysql查询:

if($property_type_search == 'HDB'){
    $find=mysql_query("SELECT*FROM package_creation WHERE property_type IN ('HDB','HDB,Private') $newcommand ORDER BY $columnname $order");
}

min loan amount sorting button: 最低贷款金额排序按钮:

<a class="link_style" href="<?php echo $_SERVER['PHP_SELF']; ?>?command=<?php echo $_GET['command']?>&columnname= min_loan_amount&<?php if($_GET['sort']== "asc"){echo "sort=desc"; $_GET['sort']="asc";}elseif($_GET['sort']=="desc"){echo "sort=asc";$_GET['sort']="desc";}elseif($_GET['sort']==""){echo "sort=asc";}?>"><img src="images/arrow_sort.png"></a>

Refilter buttons: 重新过滤按钮:

<?php
session_start();
if($_GET['FC']=='1'){
header("location:rates_results.php?command=AND lock_in_period = 'N.A' AND interest_rate_type IN ('Floating Rate(Sibor/Sor Rate)','Floating Rate(Sibor Rate)')");
}
if($_GET['FC']=='2'){
header("location:rates_results.php?command=AND lock_in_period = '1yr' AND interest_rate_type IN ('Floating Rate(Sibor/Sor Rate)','Floating Rate(Sibor Rate)')");
}
if($_GET['FC']=='3'){
header("location:rates_results.php?command=AND lock_in_period = '2yrs' AND interest_rate_type IN ('Floating Rate(Sibor/Sor Rate)','Floating Rate(Sibor Rate)')");
}
if($_GET['FC']=='4'){
header("location:rates_results.php?command=AND lock_in_period = '3yrs' AND interest_rate_type IN ('Floating Rate(Sibor/Sor Rate)','Floating Rate(Sibor Rate)')");
}
if($_GET['FC']=='5'){
header("location:rates_results.php?command=AND yrs_of_fixed_rate = '1yr' AND interest_rate_type = 'Fixed Rate'");
}
if($_GET['FC']=='6'){
header("location:rates_results.php?command=AND yrs_of_fixed_rate = '2yrs' AND interest_rate_type = 'Fixed Rate'");
}
if($_GET['FC']=='7'){
header("location:rates_results.php?command=AND yrs_of_fixed_rate = '3yrs' AND interest_rate_type = 'Fixed Rate'");
}
if($_GET['FC']=='8'){
header("location:rates_results.php?command=AND yrs_of_fixed_rate = '4yrs' AND interest_rate_type = 'Fixed Rate'");
}
if($_GET['FC']=='9'){
header("location:rates_results.php?command=AND yrs_of_fixed_rate = '5yrs' AND interest_rate_type = 'Fixed Rate'");
}
if($_GET['FC']=='10'){
header("location:rates_results.php?command=AND installation_mode IN ('Saving offset interest','Interest and Principle,Saving offset interest','Interest only, Saving offset interest','Interest and Principle,Interest only,Saving offset interest')");
}
?>

inject to mysql query: 注入mysql查询:

$columnname ="";
if($_GET['columnname']){
$columnname = $_GET['columnname'];  
}

if($columnname==""){
$columnname="first_year";   
}
if($order==""){
$order = "desc";    
}
$order=$_GET['sort'];

$newcommand = "";
if($_GET['command'] !=""){
$newcommand = $_GET['command']; 
}

检查此LOC-

command=$_GET['command'] and make it as command=<?php echo $_GET['command'] ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM