2012-06-18 2 views
0

php 및 mysql을 사용하여 디스플레이 패키지 페이지를 만들었습니다. 출력물을 다시보기 위해 10 개의 버튼이 테이블 위에 있습니다. 내가 refilter를 어떻게 사용했는지는 $_GET['command']이고 이는 'AND lock_in_period = '1yr''과 같습니다. $_GET['command']을 세션 아래에 저장하려고했지만 작동하지 않습니다. 문제는 지금 내가 출력을 refilter 후 오름차순 또는 desc 정렬 분 대출 금액을 얻을 수 없다는 것입니다.PHP 필터 및 분 단위로 정렬

출력

enter image description here

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"); 
} 

분 대출금 정렬 버튼 :

<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> 
0 개

대해 필터링 버튼 :

<?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')"); 
} 
?> 

주입 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']; 
} 
+0

당신은 어떻게'$ _GET [ '종류'를 전달하는 ]'귀하의 쿼리에? 또한'$ _GET [ 'command']'가 SQL injection 공격에 대해 열렬히 열려 있다는 것을 알아 두십시오. –

+0

아직 해결 방법을 생각하고 있습니다 .. – Psinyee

+0

'$ order'를'$ _GET [ 'order']' (이 var가 어디에서 왔는지 보지 말고)'$ _GET [ 'sort']'로 덮어 씁니다. 아마'$ order = (isset ($ _GET [ 'sort']) && $ _GET [ 'sort']) 할까? $ _GET [ 'sort'] : 'desc';'- 이것은 실제로 문제를 해결하지는 못하지만 오류가 발생하기 쉽지는 않습니다. –

답변

0

확인이 LOC -

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

여전히 정렬 할 수 없습니다. – Psinyee

+0

@Psinyee ohh okk 더 확인하겠습니다. – swapnesh

+0

@Psinyee 확실한 헤더 URL이 제대로 작동합니까? 출구를 사용하십시오; header() 다음에 문제가 해결되는지 여부를 알려주세요. db에 대한 쿼리를 만들기 전에 데이터를 초기화하여 – swapnesh

관련 문제