Copy initial letter to another field

Hi,
Hope someone can help a real newbie!
I have set a form up, where a user inputs various things - one being a surname, which goes into MySql.
I also have a category field (which was to be a drop down list of the alphabet -too long!), but I am (sorry) mis-trusting users to put their own initial letter of their surname as the catergory! i.e: Surname: Hall, catergory: H.

Is there a way (inPHP) to automatically copy the intial letter (Capatalised) of the surname and put it into the catergory field? (on submission of the form?)

These are the fields in question:
Fields:…surname,…category
Example:…simpson,…S
…bradley,…B

Many thanx

:lol: :lol:

[php]// Ensures first letter is Uppercase of surname
$surname = ucfirst($surname);
// uses only the first letter for the Category.
$category = substr($surname, 0,1);
[/php]

http://us4.php.net/manual/en/function.ucfirst.php
http://us4.php.net/manual/en/function.substr.php

Sponsor our Newsletter | Privacy Policy | Terms of Service