[eluser]Thorpe Obazee[/eluser]
I suggest you just return the result from the model and pass it to the view
[quote author="yudahebat" date="1244032293"]I have a model like this
Code:
class Crud extends Model
{
function Crud()
{
parent::Model();
}
/* PILIH DATA */
function cetak_data()
{
$this->db->query('SELECT tgl_pesan FROM reservasi WHERE tgl_pesan BETWEEN '. $this->input->post('dari_tgl').
' AND '.$this->input->post('sampai_tgl').'');
$query = $this->db->get('reservasi');
if ($query->num_rows() > 0)
{
return $query->result();
}
return FALSE;
}
}
and controller like this
Code:
function cetak_data()
{
$data['css1'] = $this->css;
$data['base'] = $this->base;
$data['menu_adm'] = $this->menu;
$data['myrobots'] = '<meta name="robots" content="noindex,nofollow">';
$data['mywebtitle'] = 'mrputucar | Cetak Data';
$data['pesan'] = $this->Crud->cetak_data();
$this->load->view('cetak_data',$data);
}
and my view like this
Code:
<h1 style="color:#E7541A;">Data User</h1>
<table width="925" border="0" cellpadding="0" cellspacing="0" class="tabel" >
<tr>
<td width="60" class="tabel"><p>TANGGAL</p></td>
<td width="90" class="tabel"><p>ID</p></td>
<td width="80" class="tabel"><p>ID USER</p></td>
<td width="150" class="tabel"><p>BIAYA TOTAL</p></td>
</tr>
<?php foreach($pesan as $r): ?>
<tr>
<td class="tabel2" valign="top"><p><?= $r->id;?></p></td>
<td class="tabel2" valign="top"><p><?= $r->user_id;?></p></td>
<td class="tabel2" valign="top"><p><?= $r->user_id;?></p></td>
<td class="tabel2" valign="top"><p><?= $r->user_id;?></p></td>
</tr>
<?php endforeach; ?>
</table>
but its didn't show the data
on $pesan just become
array on the view not the data that ive choose...
what wrong? help please...[/quote]
look above. What you did is that you overwritten your $data variable over and over which gives you just one row.
Then you didn't loop through your array so you got 'Array' as an output.