I am using this php code to generate a code
<?php
$year = date('y'); //gets 2 digits of year, ex, year 2014 as 14
$month = date('m');//gets 2 digits of month, ex, month July as 07
$day = date('d');//gets 2 digits of date, ex, date 07
$random = substr( md5(rand()), 0, 4); //generate 4 digits random number using 0-9 and a-z
$code = $year . $month . $day . $random;
echo $code;
?>
Next I am trying to add a 5 digit number to this code starting from 00001 to 99999
means the code shall look like, YYMMDDXXXXNNNNN while I have achieved YYMMDDXXXX, I am still struggling with NNNNN part (00000-99999).
How can that be made and concatenated to this variable $code with each user generate entry.
I want to mention here, this is the code number of a form, when 1st user fills the form on any date the NNNNN given to him would be 00001, for 2nd user 00002, 3rd user 00003 and so on, irrespective of any date in a particular month.
Also, When the month is changed from current to next, I want that NNNNN again to be reset to 00001.
How can I achieve those two things.
Any idea guys?
here is the snippet http://codepad.org/cgPLEtr7