Welcome Guest, Not a member yet? Register   Sign In
GET function does not work.
#1

Hey,
i have this code in my model file, which does not work for those conditions. Could you suggest any corrections?!

The url in this situation is pets?petStatus=2&petType=1 etc..etc..


My other question is "How can i get each url parameter individually, with the same results even if the order is different?!",
e.g if the above url was like pets?petType=1&petStatus=2 etc..etc..

Thank you again!

Code:
public function filter_pets($pet_entry_id = 0, $pet_entry_slug = FALSE){

     if($this->input->get('petStatus') || $this->input->get('petType') ){

       if ( $this->input->get('petStatus') ){
         $pet_data = array(
           'pet_status' => $this->input->get('petStatus')
         );
       } elseif ( $this->input->get('petType') ){
         $pet_data = array(
           'category_id' => $this->input->get('petType')
         );
       } elseif ( $this->input->get('petStatus') || $this->input->get('petType')){
         $pet_data = array(
           'pet_status' => $this->input->get('petStatus'),
           'category_id' => $this->input->get('petType')
         );
       }

       $query = $this->db->get_where('pets', $pet_data);
       return $query->result_array();
     } else {

     $query = $this->db->get('pets');
     return $query->result_array();
   }

 }

//Life motto
if (sad() == true) {
     sad().stop();
     develop();
}
Reply


Messages In This Thread
GET function does not work. - by HarrysR - 08-14-2018, 02:21 PM
RE: GET function does not work. - by php_rocs - 08-14-2018, 04:14 PM
RE: GET function does not work. - by HarrysR - 08-14-2018, 05:40 PM
RE: GET function does not work. - by php_rocs - 08-15-2018, 04:47 AM
RE: GET function does not work. - by HarrysR - 08-15-2018, 08:58 AM
RE: GET function does not work. - by php_rocs - 08-15-2018, 09:10 AM
RE: GET function does not work. - by HarrysR - 08-15-2018, 09:43 AM
RE: GET function does not work. - by php_rocs - 08-15-2018, 10:25 AM
RE: GET function does not work. - by HarrysR - 08-15-2018, 11:28 AM
RE: GET function does not work. - by HarrysR - 08-15-2018, 12:35 PM



Theme © iAndrew 2016 - Forum software by © MyBB