我需要自动编号收据数据每当我插入新的行数据时,mysql表中没有增量它仍然保持相同的收据ID 8874 不知道是不是错了
if ($param1 == 'edit' && $param2 == 'do_update') {
$data['op_number'] = $this->input->post('op_number');
$data['name'] = $this->input->post('name');
$data['ic'] = $this->input->post('ic');
$data['receipt'] = '8800';
for($i = 0; $i < 74; $i++)
{
$data['receipt']++;
if(substr($data['receipt'], 5) == '100')
{
continue;
}
}
$this->db->insert('invoice', $data);
$this->session->set_flashdata('flash_message', get_phrase('invoice_created'));
redirect(base_url() . 'index.php?receptionist/manage_invoice', 'refresh');
答案 0 :(得分:0)
你可以尝试一下
$receipt = '8800';
for($i = 0; $i < 74; $i++){
$receipt++;
if(substr($receipt, 5) == '100'){
continue;
}
}
if ($param1 == 'edit' && $param2 == 'do_update') {
$data= array{
'op_number' = $this->input->post('op_number'),
'name' = $this->input->post('name'),
'ic' = $this->input->post('ic'),
'receipt' = $receipt };
$this->db->insert('invoice', $data);
$this->session->set_flashdata('flash_message',get_phrase('invoice_created'));
redirect(base_url() . 'index.php?receptionist/manage_invoice', 'refresh');