php - Error trying to show data from db on table -
i working side project trying learn ci, got errors haven't found answer to. tried suggestions/answer die($this->db->last_query());
, var_dump
still shown error. data shown on view using <?php echo print($list_rawmat) ?>
wont show in table (same page) here's view
<?php echo print($list_rawmat) ?> <div id="list_data_rawmat"> <table class="table table-hover text-centered"> <tr> <td><b>no.</td> <td><b>jenis barang</td> <td><b>nama barang</td> <td><b>harga satuan</td> <td><b>jumlah</td> <td><b>satuan</td> <td><b>berat</td> <td><b>edit/delete</td> </tr> <?php $i = 1; foreach($list_rawmat $row) { $type = "raw material"; echo "<tr> <td>".$i++."</td> <td>".$type."</td> <td>".$row->rawmat_name."</td> <td>".$row->rawmat_price."</td> <td>".$row->qty."</td> <td>".$row->qty_nama."</td> <td>".$row->weight."</td> </tr>"; } ?> </table> </div>
here's model
*$proyek = am1 (it sent previous page) function list_rawmat($proyek){ $sql = "select * order_table g, order_detail b g.project_id = '".$proyek."' , g.order_detail_id = b.order_detail_id"; $item_id = $this->db->query($sql)->result(); $i = 0; $result = array(); foreach($item_id $row){ if ($row->rawmat_id != null) { $sql2 = "select g.order_id, g.order_date, g.total, b.qty, i.rawmat_id, i.rawmat_name, i.rawmat_price, b.weight, h.qty_nama order_table g, order_detail b, raw_material i, quantity_type h g.project_id = '".$proyek."' , b.rawmat_id = i.rawmat_id , h.qty_type_id = b.qty_type_id , g.order_detail_id = b.order_detail_id "; $query = $this->db->query($sql2); $result[$i++] = $query->result(); } } return $result; }
and lastly here's controller
*$this->session->project_id = am1 (sent view before view in question) function view_data_rawmat(){ $config['base_url'] = base_url().'index.php/c_data/index'; $config['total_rows'] = $this->m_data->count(); $config['per_page'] = 10; $config['next_link'] = 'selanjutnya'; $config['prev_link'] = 'sebelumnya'; $config['uri_segment'] = 3; $this->pagination->initialize($config); $offset=$this->uri->segment(3); $data['list_rawmat'] = $this->m_data->list_rawmat($this->session->project_id); $str_links = $this->pagination->create_links(); $data["links"] = explode(' ',$str_links ); $this->load->view ('view_header'); $this->load->view ('view_data_rawmat',$data); $this->load->view ('view_footer'); //die($this->db->last_query()); }
this result echo print_r ($list_rawmat);
array ( [0] => array ( [0] => stdclass object ( [order_id] => 5 [order_date] => 2016-04-05 [total] => 876348553 [qty] => 313 [rawmat_id] => 1 [rawmat_name] => wf - 346x174x6x9 l.9000mm [rawmat_price] => 7514 [weight] => 116624 [qty_nama] => bh ) [1] => stdclass object ( [order_id] => 6 [order_date] => 2016-11-10 [total] => 2147483647 [qty] => 10 [rawmat_id] => 2 [rawmat_name] => wf - 336x174x6x9 l.9000mm [rawmat_price] => 1848000 [weight] => 116624 [qty_nama] => sets ) ) [1] => array ( [0] => stdclass object ( [order_id] => 5 [order_date] => 2016-04-05 [total] => 876348553 [qty] => 313 [rawmat_id] => 1 [rawmat_name] => wf - 346x174x6x9 l.9000mm [rawmat_price] => 7514 [weight] => 116624 [qty_nama] => bh ) [1] => stdclass object ( [order_id] => 6 [order_date] => 2016-11-10 [total] => 2147483647 [qty] => 10 [rawmat_id] => 2 [rawmat_name] => wf - 336x174x6x9 l.9000mm [rawmat_price] => 1848000 [weight] => 116624 [qty_nama] => sets ) ) ) 1
i don't know why array that, please enlighten me too.
Comments
Post a Comment