gpt4 book ai didi

php - 通过 CodeIgniter 中的代码在收据表中自定义自动编号

转载 作者:行者123 更新时间:2023-11-30 22:11:18 26 4
gpt4 key购买 nike

每当我在 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');

最佳答案

你可以试试

$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');

关于php - 通过 CodeIgniter 中的代码在收据表中自定义自动编号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40056396/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com