Question

Here my method

public function sale($id,$type){
   if($id==TRUE){
       .....................
       .....................
    }
    if($type==TRUE){
      .......................
      .......................
    }
}

I want Browse two parameter individually, suppose

http://mysite.com/mycontroller/sale/id

and

http://mysite.com/mycontroller/sale/type

How can it possible

Was it helpful?

Solution

Try this:
URL Format : http://mysite.com/mycontroller/sale/id ( not possible )
NOW : http://mysite.com/mycontroller/sale/selector/id/value/1
NOW : http://mysite.com/mycontroller/sale/selector/type/value/1

function sale(){
   $type    = $this->uri->segment(4);  #get the selector
   $val     = $this->uri->segment(6);  #get the value
   if( $type == "id" ){
        #in id selection
   }else if( $type == "type" ){
      #in type selection
   }else{
        redirect('somewhere', 'refresh');
   }
}

OTHER TIPS

You can pass multi-params with URL:

For example following urls:

http://mysite.com/mycontroller/sale

http://mysite.com/mycontroller/sale/3

http://mysite.com/mycontroller/sale/3/computer

Here codes:

public function sale($id = false, $type = false) {

   if($id) {
       // something to do
   }

   if($type) {
      // something to do
   }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top