Return mysql rows depending on the criteria
23:52 06 Apr 2016

I have a table called payment plan which has this different fields. enter image description here

I wrote a query to get this rows but I need to modify the query in a way that when I give it a criteria that the amount is 80, which comes from a input field in the html it will only show me one field, from the table, if a I write the amount is 90 it still should show me one table but if I write the amount is 160 or 160 + it should show me both the table. This amounts are basically the CAPITAL_PAYMENT of the table. But I am not sure how to write the query. I wrote this

SELECT c.* , a.Interest
FROM investment a 
inner join money_offer b
on a.ORIG_ID = b.investment_orig_id and b.UPDATE_DT is null
inner join payment_plan c
on c.offer_orig_id = b.ORIG_ID and c.UPDATE_DT is null
WHERE a.ORIG_ID = 21 and
      a.Owner = 533  and
      a.UPDATE_DT is null;

Now I get two rows but depending on amount, if 90, I should get 1 row but I am not sure where do I write it or how.

This amount is basically coming from codeigniter function if it helps here is the code.

public function getLoansBorrowedData($id, $orig_id , $amount){
            $query = 'SELECT c.* , a.Interest , d.symbol
                      FROM investment a 
                      inner join money_offer b
                      on a.ORIG_ID = b.investment_orig_id and b.UPDATE_DT is null
                      inner join payment_plan c
                      on c.offer_orig_id = b.ORIG_ID and  c.UPDATE_DT is null
                      inner   join currency d 
                      on  c.currency = d.ID 
                      WHERE a.ORIG_ID = '.$orig_id.' and
                      a.Owner = '.$id.'  and
                      a.UPDATE_DT is null' ;

            $query = $this->db->query($query);
             /* Return either found rows or false. */ 
            if($query->num_rows() > 0){
                $result = $query->result();
                return $result;
            } 
            else {
                return false;   
            }
}
php sql mysql codeigniter