CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Seeking suggestions on capitalization

Print topic Send  topic

Author Message
Stanj

Posts: 166
Posted: 07/16/2011, 2:52 AM

Hello Chargers,
I am looking for suggestions on how to handle a report that lists names. The agency that wants the list before wanted all caps for last names so I used CSS uppercase to format the user entered names. The DB has mixed case, some people do not use any capitalization, some use proper case and others use all caps. Now the agency changed their mind and wants only the first letter capitalized. The "capitalize" format does not work because it leaves wrong case letters capitalized if entered all caps. For example
using "capitalize" on:
smith= Smith ....good
SMITH=SMITH....not good
I need to display the second and remaining letters lower case.
Any Ideas?

I can create a SQL update query to fix the DB to proper case but new names are added all the time so it is better to leave the data in the field as entered and format only on presentation.
_________________
Stan
St Petersburg Russia
View profile  Send private message
tfertil

Posts: 43
Posted: 07/16/2011, 7:03 AM

Hi Stanj,

Depending on the database you're using, maybe you can create a calculated field (this is MS-SQL terminology, I don't know the equivalent for mySql) which handles the capitalization issues at database level. Another way would be to write a trigger that capitalizes the names the way you want every time a new row is inserted or updated.

This are (I think) the best ways because with any of them you don't need to worry about capitalization in every report you write, and it provides consistency across systems and a single point for maintenance in case your client change his mind again.

Regards,
View profile  Send private message
datadoit
Posted: 07/16/2011, 9:17 AM

Sounds like you'll want to take the string and all caps it or all
lowercase it, then use PHP functions to format the way you want. See:

http://www.php.net/manual/en/function.ucwords.php
Stanj

Posts: 166
Posted: 07/16/2011, 2:24 PM

Thank you for the relies.
Maybe I did not understand the details of "ucwords" because I was under the impression that it would capitalize each word but not set the subsequent letters of the name to lower case if it was in the record with all upper case. I can see by one of the examples that it can do just what I need...Now I just have to figure out the details of using it in CCS. Thanks for putting me on the right track.
From the examples:
$bar = 'HELLO WORLD!';
$bar = ucwords(strtolower($bar)); // Hello World!

Stan
_________________
Stan
St Petersburg Russia
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.