Gossamer Forum
Home : Products : DBMan : Customization :

numer to alpha

Quote Reply
numer to alpha
suppose i have a field named "number" and is the the database key as well (with db tract enabled). then i have another field named "referencenum" which is set as alpha and should contain for ex., "ABCD00001" where the last 5 char (00001) is the value of the "number" field with the corresponding number of 0's prepended to it.

please help!
Quote Reply
Re: numer to alpha In reply to
Where does the "ABCD" part come from?

Is it entered by the user?

------------------
JPD





Quote Reply
Re: numer to alpha In reply to
the ABCD part should be entered by the user.
Quote Reply
Re: numer to alpha In reply to
So the user enters a series of letters and you want to append the "number" which has been expanded to 5 digits?

Okay.

In sub add_record (db.cgi), just after

Code:
# Set the userid to the logged in user.
($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);

add

Code:
$in{'referencenum'} .= '0' x (5 - length($in{'number'})) . $in{'number'};


------------------
JPD





Quote Reply
Re: numer to alpha In reply to
thanks a lot jpd.