Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP filter and sort by min amount
    text
    copied!<p>I've created a display package page with php and mysql. There're 10 buttons on top of the table to refilter the output. How I did the refilter is by using <code>$_GET['command']</code> which is equal to '<code>AND lock_in_period = '1yr'</code>. I've tried to save <code>$_GET['command']</code> under session, but it doesn't work. The problem now is I can't get the min loan amount to sort asc or desc after I refilter the output.</p> <p><strong>output</strong></p> <p><img src="https://i.stack.imgur.com/evrNG.png" alt="enter image description here"></p> <p><strong>mysql query:</strong></p> <pre><code>if($property_type_search == 'HDB'){ $find=mysql_query("SELECT*FROM package_creation WHERE property_type IN ('HDB','HDB,Private') $newcommand ORDER BY $columnname $order"); } </code></pre> <p><strong>min loan amount sorting button:</strong></p> <pre><code>&lt;a class="link_style" href="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;?command=&lt;?php echo $_GET['command']?&gt;&amp;columnname= min_loan_amount&amp;&lt;?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";}?&gt;"&gt;&lt;img src="images/arrow_sort.png"&gt;&lt;/a&gt; </code></pre> <p><strong>Refilter buttons:</strong></p> <pre><code>&lt;?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')"); } ?&gt; </code></pre> <p><strong>inject to mysql query:</strong></p> <pre><code>$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']; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload