?
Solved

Changing the CASE of letters in Output

Posted on 2011-03-23
7
Medium Priority
?
291 Views
Last Modified: 2013-12-13
Hello Folks,

I would like to change the upper case of certain letters of the output from a certain column in a table..

e.g 1 here making the first letter in the output in Caps and the rest in all lowercase letters

before:
select , description, price from tbl_name
output SONY BLU-RAY INTERNAL DRIVE SATA (BLACK), $9.99

after:
select , description, price from tbl_name
output Sony blu-ray internal drive(black), $9.99


e.g 2 here making the first letter of every word in the output in Caps and the rest in all lowercase letters

before:
select , description, price from tbl_name
output SONY BLU-RAY INTERNAL DRIVE SATA (BLACK), $9.99

after:
select , description, price from tbl_name
output Sony Blu-ray Internal Drive(Black), $9.99


thanks in advance
0
Comment
Question by:Eaddy Barnes
7 Comments
 
LVL 14

Expert Comment

by:Scott Madeira
ID: 35201805
you can do this for example 1:

$string = ucfirst(strtolower($string));

example two you could use:

$string = ucwords(strtolower($string));

May be some issues with the words inside (), though.  You will need to play with it.
0
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 35201807
Hi,


example 1:
$mystring = "HELLO HOW ARE YOU TODAY";
$mystring = ucfirst(strtolower($mystring));

example 2:
$mystring = "HELLO HOW ARE YOU TODAY";
$mystring = ucwords($mystring);
0
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 35201812
lol, beat me to it smadeira... :P

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 11

Author Comment

by:Eaddy Barnes
ID: 35203982
hey guys i'm not using php at all for the output only mysql queries.
0
 
LVL 41

Accepted Solution

by:
Sharath earned 2000 total points
ID: 35204103
To get the first output, try like this.
SELECT CONCAT(UPPER(SUBSTRING(description,1,1)),LOWER(SUBSTRING(description,2))) AS description,
       price 
  FROM tbl_name

Open in new window

0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 35204797
Why is it in the PHP zone then ? You are using PHP, there has to be some layer between the database and the page. And the easiest way to do what you want is to present data like jrm213jrm213 did.
0
 
LVL 11

Author Comment

by:Eaddy Barnes
ID: 35207526
It being in PHP Zone was my error..
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question