I am trying to retrieve the columns from the database based on checkbox selection in codeigniter. But I have no idea how to do it?
For example there's a columns in a database table Member:
| ID | Name | Gender | Status |
---------------------------------------
| 1 | Anne | F | Member |
| 2 | Brown | M | Member |
| 3 | Carl | M | Member |
Then there's checkboxes in the data.php view to select which column to display
<?php echo form_open(data/getData);?>
<label class="col-md-4" for="parameter">Parameter</label>
<div class="col-md-6">
<input type="checkbox" id="parameter" value="name"> Name <br>
<input type="checkbox" id="parameter" value="gender"> Gender <br>
<input type="checkbox" id="parameter" value="status"> status <br>
</div>
<input type="submit" class="btn btn-md btn-info" value="Process" />
<?php echo form_close();?>
Data_model.php:
function getData(){
//I don't know how to get the dynamic column select from the view to the select query
$this->db->select(?);
$this->db->from('member');
$query = $this->db->get();
return $query->result();
}
Anyone help me with this please?
Aucun commentaire:
Enregistrer un commentaire