Home | Site map   
  Home Products Downloads Support Contacts
 

HowTo: Write names to the database in proper case

Sometimes you need to write names to the database in proper case ("bill gates" => "Bill Gates"). This tutorial will show you the steps you need to follow.

Open your ASPRunner/PHPRunner project and proceed to Events tab
Double click on Before Record Updated Event for Edit page
Choose from one of the predefined actions Custom Code and click OK

Modify sample event code putting to appropriate place following code snippets

ASPRunner Example
str = dict("UserName")
for i=1 to len(str)
if (i=1) then
b = true
else
b = ( Mid(str, i-1, 1)=" " )
end if
if b then _
str = left(str, i-1) & UCase(Mid(str, i,1)) & Mid(str, i+1)
next
dict("UserName")=str
 
PHPRunner Example
$str = $values["UserName"];
for ($i=0; $i<strlen($str); $i++){
if ($i==0) {
$b = True;
}
else
$b = (substr($str, $i-1,1) == " ");
if ($b)
$str = substr($str,0,$i).strtoupper(substr($str, $i,1)).substr($str, $i+1);
}
$values["UserName"] = $str;

Make the same for Before Record Added Event

These changes will apply to UserName field. Now, this field will be written to the database using capitals where appropriate. For example, after adding new user "sam fowler" new record will be created with "Sam Fowler" value in UserName field.

Applies to:
ASPRunner Pro
PHPRunner

Back to top

 
 

Home | Products | Downloads | Support | Contacts

  © 1999 - 2006 XLineSoft. All rights reserved. All comments send to webmaster@xlinesoft.com