8
I have a database with a table called tblapoio
, with 4 fields (id
, descricao
, valor
, tag
)
Needed to make a form with a list of checkboxes with these values that exist in the table.
I am using Codeigniter.
Follow a picture of what I want:
Right now I have this model:
public function apoioPertendido(){
$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:
public function apoioPertendido(){
$query = $this->db->get('tblapoio');
return $query->result();
}
CONTROLER:
public function proporEvento(){
$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'] = 'Propor Evento';
$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>Apoio Pertendido</label>
<div class="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>
please explain better and if you’ve already made some part of the code try to post here.
– rafaelphp
Post the resolution in the answer area, not in the question itself.
– vinibrsl