php - Conditional select from a table using codeigniter -


im trying make select shows information (a conditional select).

i mean, table "usuarios":

"usuarios" includes:(id,username,name,lastname,password,type,status,date)

take look:

enter image description here

my goal make select shows users "type" = 1 , "status" = 1

take look:

enter image description here

i have done select shows every usernames, not validates :/.

my program shows this, , not correct because not validate :/

enter image description here

here code:

my controller file:

    public function edit($id){    $data['usuarios'] = $this->crudmodel->get_usuarios();   $data['record']=$this->crudmodel->get_id_row($id);   $this->load->view('edit',$data);  } 

my model file:

          public function get_usuarios() {          $this->db->select('c.*')              ->from('usuarios c');         $q = $this->db->get();            return $q->result(); } 

my "edit" file:

    <h2 align="center">update</h2> <form method="post" action='<?php echo site_url('home/saveupdate'); ?>'> <tr>      <td><input type="text" hidden name="txtid" value="<?php echo $record->id ?>"/></td>  </tr> <tr>      <td>         <select name="txtcarr">             <?php foreach($usuarios $item):?>             <option value="<?php echo $item->id;?>"><?php echo $item->username;?></option>              <?php endforeach;?>         </select>     </td> </tr>   <tr>      <td></td>     <td><input type="submit" value="save"/></td>  </tr> 

dont know whatto :/

why not select rows want? work expect if put in model?

public function get_usuarios() {    $this->db->select('id, username')         ->from('usuarios')         ->where(array('status'=>1, 'type'=>1));     $q = $this->db->get();    return $q->result(); } 

Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -