[eluser]Jauhari[/eluser]
I am newbie in CI and I really enjoy with this framework.
I have question about how to sort or add where condition.
This is my detail problem.
I was made some tabular data with some field, example name and email. then I was succesfully display my tabular data on my view.
My Question is, how to sorting my data? on my tables I have some date added. And I want make simple form, where I can input some value (example input data added on 2/2/2008 only) and my tabular data automatically will change to current data on 2/2/2008 only.
How to do that? please help me.
I was try add this code on my controllers
Code:
function address() {
$this->load->helper('form');
$this->db->select('nama,email,date');
$this->db->where('date','$date');
$this->db->from('address');
$data['query'] = $this->db->get();
$this->load->view('address', $data);
}
And code on my Views
Code:
<form action="" method="POST">
<?php
$datas = array(
'name' => 'date',
'id' => 'date',
'value' => '8',
'maxlength' => '100',
'size' => '50',
'style' => 'yellow',
);
$date = form_input($datas);
echo $date;
?>
<button type="submit" class="button positive">
Submit
</button>
</form>
<table class="data">
<tr class="head">
<th id="nid" rowspan="2" scope="col">No.</th>
<th id="nper" rowspan="2" scope="col">Name</th>
<th rowspan="2" scope="col">Email</th>
</tr>
<?php
$i = 1;
if ($query->num_rows() > 0):
foreach ($query->result() as $row):
?>
<tr class="<?php if($i%2 == '0'): echo "alt"; else: echo "row"; endif; ?>">
<td class="td-center"><?php echo $i;$i++;?></td>
<td class="td-center"><?php echo $row->name;?></td>
<td class="td-center"><?php echo $row->email; ?></td>
</tr>
<?php
endforeach;
endif;
?>
</table>
But my sorting doesn't work
Please Help Me