2016-04-29 2 views
1

Ansicht Teil, wo der Fehler aufgetretenEin PHP-Fehler aufgetreten Schwere: Der Versuch, nicht-Objekt Dateinamen zu erhalten:

<select name="standard" class="form-control"> 
    <option <?php if($course->medium =='E'){ echo "selected";} ?> value="English" >English</option> 
    <option <?php if($course->medium =='M'){ echo "selected";} ?> value="Malayalam">Malayalam</option> 
</select> 

Modellteil

public static function getStandard($id){ 

    $this->db->select("*"); 
    $this->db->from('standard'); 
    $this->db->where('id',$id); 

    $res=$this->db->get(); 

    foreach($res->result() as $value) { 

     return $value; 
    } 

} 

Controller Teil

public function add_standard($action='',$id='') { 

     $this->load_syles(); 

     $course = array(); 
    if ($action == 'edit' and $id != '' and is_numeric($id)) { 
    $course = $this->news_model->getStandard($id); 
    } 

    $this->data['course'] = $course ; 

    $this->data['title'] = 'Add Standard'; 
    $this->data['page_header'] = "Add Standard"; 
    $this->data['page_header_desc'] = "Add Standard"; 
    $details=$this->news_model->viewAllStandard(); 
    $this->data['details']=$details; 
    $this->data['count']=count($details); 
    $this->data['is_edit']=$action; 
+0

Ihr Fetching Objekt als Array .Sie wie diese verwendet werden sollen: Statt < ? php if ($ Kurs-> Medium == 'E') {Echo "ausgewählt";}?> – JYoThI

Antwort

0

Sie haben

$course = array() 
012 geschrieben

und dann verwendet

$course->medium 

, als ob es ein Objekt

war man $course['medium'] in der Ansicht (html)

0

Ändern Sie Ihr Modell wie

public static function getStandard($id) 
{ 
    $this->db->select("*"); 
    $this->db->from('standard'); 
    $this->db->where('id',$id); 
    $res=$this->db->get(); 
    return $res->row_array(); 
} 

ändern verwenden sollten $course->medium zu $course['medium']

<select name="standard" class="form-control"> 
<option <?php if($course['medium'] =='E'){ echo "selected";} ?> value="English" >English</option> 
<option <?php if($course$course['medium'] =='M'){ echo "selected";} ?> value="Malayalam">Malayalam</option> 

Verwandte Themen