Solved

Changing the CASE of letters in Output

Posted on 2011-03-23
7
281 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:greeneel
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 11

Author Comment

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

Accepted Solution

by:
Sharath earned 500 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:greeneel
ID: 35207526
It being in PHP Zone was my error..
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now