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.

Steps:

Open your ASPRunner/PHPRunner project and proceed to Events tab
Click on Before Record Updated Event for Edit page

Modify sample event code putting to appropriate place following code snippets

ASPRunner Example
str = values("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
values("UserName")=str
 
PHPRunner Example
$arr = explode(" ",$values["UserName"]);
for ($i=0; $i < count($arr); $i++)
$arr[$i] = ucfirst($arr[$i]);
$values["UserName"]=implode(" ",$arr);

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.

Note: Changes in SQL Query maybe different according to database used. For example, for MSSQL, MySQL, Oracle and Postgre SQL databases you should use Upper operator instead of Ucase.

Applies to:
ASPRunner Pro
PHPRunner

Back to top

 
 

Home | Products | Downloads | Support | Contacts

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