我想知道在Codeigniter中执行此操作最相关的方法。我实际上是用它填充表格
<div class="form-group">
<label for="int">Clients Id <?php echo form_error('clients_id') ?></label>
<select class="form-control select2 select2-hidden-accessible" se="width: 100%;">
<center><option selected="selected">--- Select ---</option></center>
<?php
foreach ($invoices as $invoices) {
?>
<option class="form-control select2" value=" <?php echo $invoices->clients_id; ?>"><?php echo $invoices->first_name; ?>
</option>
<?php
}
?></select>
</div>
<div class="form-group">
<label for="int">Suppliers Id <?php echo form_error('suppliers_id') ?></label>
<select class="form-control select2 select2-hidden-accessible" se="width: 100%;">
<center><option selected="selected">--- Select ---</option></center>
<?php
foreach ($invoices as $invoices) {
echo "<pre>"; print_r($invoices);die;
?>
<option class="form-control select2" value=" <?php echo $invoices->service_id; ?>"><?php echo $invoices->service_name; ?>
</option>
<?php
}
?></select>
</div>
此功能在我的模型中。有什么最好的执行方法。
function join() {
$this->db->select('*');
$this->db->from('invoices');
$this->db->join('clients', 'invoices.id = clients.id');
$this->db->join('services', 'invoices.id = services.id');
$query = $this->db->get();
return $query->result();
}
这是正确的方法。调用发票数据。实际上,整个代码都能正常工作,但是当我调用foreach()
时,显示错误。谢谢你。
public function create()
{
$data = array(
'button' => 'Create',
'action' => site_url('invoices/create_action'),
'id' => set_value('id'),
'clients_id' => set_value('clients_id'),
'services_id' => set_value('services_id'),
'suppliers_id' => set_value('suppliers_id'),
'contractors_id' => set_value('contractors_id'),
'charges_id' => set_value('charges_id'),
'particulars' => set_value('particulars'),
'details' => set_value('details'),
'price' => set_value('price'),
'date' => set_value('date'),
'due' => set_value('due'),
'paid' => set_value('paid'),
);
$this->load->view('invoices_form', $data);
}
答案 0 :(得分:0)
首先使用echo $this->db->last_query();
检查查询,然后将此代码放在您编写controller
的{{1}}中,然后检查其是否工作,然后在$data['invoices']
中使用以下代码部分。
view