following youtube tots
i want to auto increase registration number
model code
Code:
public function auto() {
$registerNO = "SPPS";
$query = 'select max(registerNO) as registerNO_auto from student';
$data = $this->db->query($query)->row_array();
$max_registerNO = $data['registerNO_auto'];
$max_registerNO2 = (int)substr($max_registerNO,7,3);
$registerNOcount = $max_registerNO2+1;
$registerNO_auto = $registerNO."-".sprintf('%03s', $registerNOcount+1);
return $registerNO_auto;
}
view code
Code:
<?php
$registerNO = $this->student_m->auto();
echo form_input([
'name'=> 'registerNO',
'class'=>'form-control',
'value'=>set_value('registerNO', $registerNO),
'readonly'=>'true'
]);
?>
my output is static as "SPPS-0001" there is no increament whenever i try adding new member