Jump to content

Unique account numbers


guymclaren

Recommended Posts

I have a need to create unique account numbers based on three letters and 3 numbers. I want to create a little script to check the surname. In ASP I can select the first three letters after the space eg Input "Guy McLaren" I want to select the MCL and then add 3 numbers to it. the first MCL would be 001 the next would be 002 etc.

 

Is there an easy way to do this? Or would it be simpler for me to use the unique id created in the database as a UID?

 

My initial thoughts are

1. find the space and select the letters

2. Check database for account numbers starting with MCL and check last number

3. seperate number from string

4. add one

5. join string

 

Will that be the best way?

 

 

Link to comment
Share on other sites

IF you do want to use a completely random number like the last poster suggested just use this function

 

function create_random_str($length){
$src = 'abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ@_';
$len = strlen($src) - 1;

$randstr = "";

for($i=0; $i<$length; $i++) 
{ 
	$x = rand(0,$len);
	$randstr .= $src{$x};
}	
return $randstr;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.