How to call codeigniter controller function from view

后端 未结 14 1746
小蘑菇
小蘑菇 2020-11-27 05:53

How to call codeigniter controller function from view? When i call the function in a controller, get a 404 page.

14条回答
  •  北海茫月
    2020-11-27 06:36

    Try this one.

    Add this code in Your View file

    $CI     = & get_instance();
    $result = $CI->FindFurnishName($pera);
    

    Add code in Your controller File

    public function FindFurnishName($furnish_filter)
    

    {

    $FindFurnishName        = $this->index_modal->FindFurnishName($furnish_filter);  
    $FindFurnishName_val    = '';
    foreach($FindFurnishName as $AllRea)
    {
        $FindFurnishName_val  .= ",".$AllRea->name;
    }
    return ltrim($FindFurnishName_val,',');
    

    }

    where

    1. FindFurnishName is name of function which is define in Your Controller.
    2. $pera is a option ( as your need).

提交回复
热议问题