Auto Increment ID’s of 4 digit

Make id as varchar and use php to make id like this

<?php
for($i=0;$i<10+27;$i++){
  $number = base_convert($i,10,10+26);//here 26 is for a-z
  $number = str_pad($number, 4, '0', STR_PAD_LEFT);
  echo " ".$number;
}
?>

Live demo : https://eval.in/854013

I hope you can get last inserted id and then increment id by 1 as in loop above to insert new record.

output of above php code is :

0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000a 000b 000c 000d
000e 000f 000g 000h 000i 000j 000k 000l 000m 000n 000o 000p 000q 000r
000s 000t 000u 000v 000w 000x 000y 000z 0010

Leave a Comment