[eluser]yudahebat[/eluser]
I have a controller
Code:
function v_cart()
{
$data['css'] = $this->css;
$data['base'] = $this->base;
$data['menu_web'] = $this->menu;
$data['myrobots'] = '<meta name="robots" content="noindex,nofollow">';
$data['mywebtitle'] = 'mrputucar | Your cart';
$this->output->enable_profiler(TRUE);
$this->session->set_userdata(array('nama' => $this->input->post('nama'),'photo' => $this->input->post('photo'),'harga' => $this->input->post('harga'),'renttgl' => $this->input->post('renttgl'),'rettgl' => $this->input->post('rettgl')));
$this->load->view('v_cart',$data);
}
and view
Code:
<?php echo form_open('mrputucar/update_cart'); ?>
<table width="645" border="0" cellpadding="0" cellspacing="0" class="tabel" >
<tr>
<td width="130" class="tabel" align="center"><p>Car Type</p></td>
<td width="110" class="tabel" align="center"><p>Rent date</p></td>
<td width="110" class="tabel" align="center"><p>Return date</p></td>
<td width="80" class="tabel" align="center"><p>Duration</p></td>
<td width="100" class="tabel" align="center"><p>Price/day</p></td>
<td width="110" class="tabel" align="center"><p>Suhtotal</p></td>
</tr>
<?php $query = $this->session->userdata();
$user_array = $query->result_array();
if(count($user_array) > 0)
{
foreach($user_array as $ua)
{ ?>
<tr>
<td width="130" class="tabel"><p><?= $ua['nama'];?></p></td>
<td width="110" class="tabel"><p><?= $ua['renttgl'];?></p></td>
<td width="110" class="tabel"><p><?= $ua['rettgl'];?></p></td>
<td width="80" class="tabel"><p><?= (strtotime($this->session->userdata('rettgl')) - strtotime($this->session->userdata('renttgl'))) / 86400;?> day</p></td>
<td width="100" class="tabel"><p>$ <?= $ua['harga'];?></p></td>
<td width="110" class="tabel"><p>$ <?= ((strtotime($this->session->userdata('rettgl')) - strtotime($this->session->userdata('renttgl'))) / 86400) * $this->session->userdata('harga');?></p></td>
</tr>
<tr>
<td colspan="4" class="tabel2"><p><?php echo form_submit('', 'send request'); ?></p></td>
<td class="tabel2"><p>Total</p></td>
<td class="tabel2"><p>$...</p></td>
</tr>
<?php }
} ?>
</table>
<?php echo form_close(); ?>
when I run it, the array didn't work
its error
Code:
A PHP Error was encountered
Severity: Warning
Message: Missing argument 1 for CI_Session::userdata(), called in C:\xampp\htdocs\CI2\system\application\views\v_cart.php on line 22 and defined
Filename: libraries/Session.php
Line Number: 420
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: item
Filename: libraries/Session.php
Line Number: 422
Code:
Fatal error: Call to a member function result_array() on a non-object in C:\xampp\htdocs\CI2\system\application\views\v_cart.php on line 23
line 23 :
Code:
$user_array = $query->result_array();
whats wrong? I just wanna show my session on array. so every I input data from another views it will show as a session without replace last entry data
looks like cart system...