mysql - How do i generate a code like this DEL-1234 in php -


hey guys please new php mysql, trying generate code del-12345. if person chooses state delaware in form, generates , stores del-23413 in db on submit. del (first 3 letters of state); - (hyphen) , 12345 (5 random numbers)...

please help

i point in right direction code below.

$area = "utah"; $code = strtoupper(substr($area, 0, 3)) . "-" . (mt_rand(1000,9999)); echo ( $code ); 

however, note code subject errors example: if $area variable contained string less 3 characters? if random value generated not unique (the theory being want be)

all of needs checked, you, give go - can if needed wont write whole code you.

good luck!


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -