?
Solved

Changing the CASE of letters in Output

Posted on 2011-03-23
7
Medium Priority
?
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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 dynamically set the form action using jQuery.
Suggested Courses

777 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