Auto generate unique number and store in DB

Hello folks, I want to auto generate a Unique number each the form is launched and store it in a Database when the form is submitted. and be able to call it when needed.

Any help will be fully appreciated.

I copied this from one of my snippets. I hope you understand it. I use class, so it’s a method… Just re-frame the style to your style.

`
public function createIdentity(){
global $gc;
$num = rand(date(“yd”).time(), time()).rand(date(“md”).time(), time());
$identity = substr(str_replace("-","", $num), 0, 15);
if(strlen($identity) < 12):
return self::createIdentity(); //Re-generate
else:
$doQuery = $gc[‘db’]->doQuery(“SELECT ph_identity FROM “. DB__PHOTOS .” WHERE ph_identity = '”.$identity."’ LIMIT 1");
if($gc[‘db’]->numRows($doQuery) > 0):
return self::createIdentity(); //Re-generate
else:
return $identity;
endif;
endif;
}
?>

thanks Silas. thats helpful

am glad it’s helpful… weldone