我只是想问。如何在数据库表中获取字段“ID”的值。我在我的模型中有这个代码:
public function select_queries($get_table){
$this->load->library('table');
$query = $this->db->get($get_table['ninja7']);
$tmpl = array('table_open' => '<table id="tbl_allinventory">',
'heading_row_start' => '<tr id="tbl_allinventory_tr1">',
'heading_row_end' => '</tr>',
'row_start' => '<tr name="">',
'cell_start' => '<td>',
'cell_end' => '</td>',
'row_end' => '</tr>',
'table_close' => '</table>');
$this->table->set_template($tmpl);
$sample_query = $this->table->generate($query);
return $sample_query;
}
以下是我的观点:
<div class="row">
<form action="add_all_inventory" method="POST" id="frm_add_all_inventory">
<h3><input type='text' name="table1" id="table1" value='<?php echo $table1; ?>' style='border: none; background-color: transparent;' readonly/></h3>
<button type="button" style='position: absolute; top:275px; right: 173px;' class='btn_addinventory btn-success btn-sm' id='btn_addinventory' name='btn_addinventory'><span class='glyphicon glyphicon-plus'></span> Add Inventory</button>
</form>
<div class="table_design">
<?php echo $select1; ?>
</div>
<div class="modal fade" id="edit_all_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" >
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
</div>
<div class="modal-body">
<iframe scrolling='0' style="width: 100%; height: 60%; border: none;" frameborder="0" src="<?php echo site_url('inventorysys_controller/edit_all_views'); ?>/<?php echo $table1; ?>"></iframe>
<div class="modal-footer">
</div>
</div>
<!--<input type="text" value="<?php echo $table1; ?>"/>-->
</div>
</div>
</div>
</div>
这是我的控制器:
public function inventory_tables(){
$tablenaming1 = $_POST['ninja7'];
$this->session->userdata('login_session');
$this->data['title'] = "Inventory";
$this->load->vars($this->data);
$this->load->view('homeview');
$select_inv['inventorytype'] = $this->inventory_model->select_tables();
$this->load->view('inventoryview', $select_inv);
$sample['sample'] = $this->inventory_model->select_fields_2($_POST['ninja7']);
$select_details['select'] = $this->inventory_model->select_queries($this->input->post());
$select_details1['select2'] = $this->inventory_model->select_queries3($this->input->post());
$value_array = array('sample1' => $sample['sample'],
'table1' => $tablenaming1,
'select1' => $select_details['select'],
'select3' => $select_details1['select2']);
$this->load->view('sampleviewtable', $value_array);
$this->load->view('footer_view');
}
我希望你能帮助我。我需要获取ID,因为当我想更新某些列时,我需要它作为参考。预先感谢您的帮助。