I have a database with a table named tblapoio
, with 4 fields ( id
, descricao
, valor
, tag
)
I needed to make a form with a list of checkboxes with those values that exist in the table.
I'm using CodeIgniter.
Here is an image of what I want:
AtthismomentIhavethismodel:
publicfunctionapoioPertendido(){$query=$this->db->get('tblapoio');if($query->num_rows()>0){foreach($query->result()as$rows)){$apoio=array('idapoio'=>$rows->idApoio,'descricao'=>$rows->descricao,'valor'=>$rows->valor,'tag'=>$rows->tag,);}return$apoio;
RESOLVED:
MODEL:
publicfunctionapoioPertendido(){$query=$this->db->get('tblapoio');return$query->result();}
CONTROLER:
publicfunctionproporEvento(){$natureza=$this->evento_model->naturezaEvento();$apoio=$this->evento_model->apoioPertendido();$espaco=$this->evento_model->espaco();$material=$this->evento_model->material();$suportgraf=$this->evento_model->suporteGrafico();$audiovisual=$this->evento_model->audioVisual();$data['title']='ProporEvento';$data['naturezaEvento']=$natureza;$data['apoioPertendido']=$apoio;$data['espaco']=$espaco;$data['material']=$material;$data['suporteGraf']=$suportgraf;$data['audioVisual']=$audiovisual;$this->load->view('cliente/clienteheaderdash_view',$data);$this->load->view('cliente/clientemenu_view',$data);$this->load->view('cliente/clienteproporevento_view',$data);$this->load->view('cliente/clientefooterdash_view',$data);}
VIEW:
label>ApoioPertendido</label><divclass="form-group">
<?php foreach ($apoioPertendido as $row) { ?>
<label>
<input type="checkbox" class="flat-red" name="<?php echo $row->tag ?>" value="<?php echo $row->idApoio ?>"/> <?php echo $row->descricao; ?>
</label>
</br>
<?php } ?>
</div>