I want to generate random number of 6 digit in mysql.
For example,
I have a table named as DATA and columns are job_name and job_id. So, when user insert value in job_name and the value of job_id which would be random and unique number which will be stored in database automatically.
I have been searched for this but can not get anything out of it. So, Please specify your answer in brief.
job_idprimary key and doAUTO_INCREMENTto start from 100000.function randomkey( $length ) { $chars = "0123456789"; return substr(str_shuffle($chars),0,$length); }You can also make it more unique by adding current timestamp. like$key = randomkey(10) . date('dmYHis');