我正在尝试学习CI这个方面的项目,但目前有一些我没有找到答案的错误。我已经尝试了一些建议/答案,例如die($this->db->last_query());
和var_dump
但它仍然显示错误。
我使用<?php echo print($list_rawmat) ?>
在我的视图中显示了数据
但它不会出现在表格中(同一页面)
这是视图
<?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 as $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>
这是模型
*$proyek = AM1 (it was sent by previous page)
function list_rawmat($proyek){
$sql = "SELECT * FROM order_table g, order_detail b
WHERE g.project_id = '".$proyek."' AND g.order_detail_id = b.order_detail_id";
$item_id = $this->db->query($sql)->result();
$i = 0;
$result = array();
foreach($item_id as $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
FROM order_table g, order_detail b, raw_material i, quantity_type h
WHERE g.project_id = '".$proyek."' AND b.rawmat_id = i.rawmat_id
AND h.qty_type_id = b.qty_type_id AND g.order_detail_id = b.order_detail_id ";
$query = $this->db->query($sql2);
$result[$i++] = $query->result();
}
}
return $result;
}
最后这里是控制器
*$this->session->project_id = AM1 (sent from view before the 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());
}
这是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
我不知道为什么阵列是这样的,请也赐教我。