I followed youtube tutorial but my codes are not working
I want to auto increase registration number
this is what I tried
in model code
in view
this is what i want to get SPPS-0000001 and it should be auto increamental
what am doing wrong
is there a better way to get the same result than this
I want to auto increase registration number
this is what I tried
in model code
PHP Code:
public function auto() {
$regNO = "reg";
$query = 'select max(registerNO) as regNO_auto from student';
$data = $this->db->query($query)->row_array();
$max_regNO = $data['regNO_auto'];
$max_regNO2 = (int)substr($max_regNO,7,3);
$regNOcount = $max_regNO2+1;
$regNO_auto = $regNO."-".sprintf('%07s', $regNOcount);
return $regNO_auto;
}
PHP Code:
<?php
$regNO = $this->members_m->auto();
echo form_input([
'name'=> 'registerNO',
'class'=>'form-control',
'value'=>set_value('registerNO', $regNO),
'readonly'=>'true']);
?>
what am doing wrong
is there a better way to get the same result than this